provide get-page function with appropriate parameters
This commit is contained in:
parent
fc310a154b
commit
9a91a59247
4 changed files with 19 additions and 11 deletions
|
@ -10,4 +10,5 @@
|
||||||
|
|
||||||
(let ((cfg (config:add *config* :client
|
(let ((cfg (config:add *config* :client
|
||||||
:class 'client:config
|
:class 'client:config
|
||||||
:base-url "http://localhost:8899"))))
|
:base-url "http://localhost:8899"
|
||||||
|
:doc-path "/" :api-path "/api/"))))
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
(:local-nicknames (:config :scopes/config)
|
(:local-nicknames (:config :scopes/config)
|
||||||
(:core :scopes/core)
|
(:core :scopes/core)
|
||||||
(:client :scopes/web/client)
|
(:client :scopes/web/client)
|
||||||
|
(:message :scopes/core/message)
|
||||||
(:server :scopes/web/server)
|
(:server :scopes/web/server)
|
||||||
(:t :scopes/testing))
|
(:t :scopes/testing))
|
||||||
(:export #:run)
|
(:export #:run)
|
||||||
|
@ -32,6 +33,7 @@
|
||||||
(== (parse-integer (server:port cfg)) 8899)))
|
(== (parse-integer (server:port cfg)) 8899)))
|
||||||
|
|
||||||
(t:deftest test-client ()
|
(t:deftest test-client ()
|
||||||
(let ((ctx (core:find-service :client)))
|
(let ((ctx (core:find-service :client))
|
||||||
|
(msg (message:simple-message '(:test :get-page) '(:path "demo.html"))))
|
||||||
(== (client:base-url (core:config ctx)) "http://localhost:8899")
|
(== (client:base-url (core:config ctx)) "http://localhost:8899")
|
||||||
(== (client:send-request ctx nil) "Hello World!")))
|
(== (client:get-page ctx msg) "Hello World!")))
|
||||||
|
|
|
@ -3,19 +3,23 @@
|
||||||
(defpackage :scopes/web/client
|
(defpackage :scopes/web/client
|
||||||
(:use :common-lisp)
|
(:use :common-lisp)
|
||||||
(:local-nicknames (:config :scopes/config)
|
(:local-nicknames (:config :scopes/config)
|
||||||
(:core :scopes/core))
|
(:core :scopes/core)
|
||||||
(:export #:config #:base-url
|
(:message :scopes/core/message))
|
||||||
#:send-request))
|
(:export #:config #:base-url #:api-path #:doc-path
|
||||||
|
#:get-page))
|
||||||
|
|
||||||
(in-package :scopes/web/client)
|
(in-package :scopes/web/client)
|
||||||
|
|
||||||
(defclass config (config:base)
|
(defclass config (config:base)
|
||||||
((config:setup :initform #'core:default-setup)
|
((config:setup :initform #'core:default-setup)
|
||||||
(base-url :reader base-url
|
(base-url :reader base-url :initarg :base-url :initform "http://localhost:8135")
|
||||||
:initarg :base-url
|
(doc-path :reader doc-path :initarg :doc-path :initform "/")
|
||||||
:initform "http://localhost:8135")))
|
(api-path :reader api-path :initarg :api-path :initform "/api/")))
|
||||||
|
|
||||||
;;;; client context (= service)
|
;;;; client context (= service)
|
||||||
|
|
||||||
(defun send-request (ctx msg)
|
(defun get-page (ctx msg)
|
||||||
(dex:get (base-url (core:config ctx))))
|
(let* ((cfg (core:config ctx))
|
||||||
|
(path (getf (message:data msg) :path))
|
||||||
|
(url (str:concat (base-url cfg) (doc-path cfg) path)))
|
||||||
|
(dex:get url)))
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
(defvar *listener* nil)
|
(defvar *listener* nil)
|
||||||
|
|
||||||
(defun app (env)
|
(defun app (env)
|
||||||
|
(print env)
|
||||||
'(200 (:content-type "text/plain") ("Hello World!")))
|
'(200 (:content-type "text/plain") ("Hello World!")))
|
||||||
|
|
||||||
(defun start (cfg)
|
(defun start (cfg)
|
||||||
|
|
Loading…
Add table
Reference in a new issue