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
|
||||
: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)
|
||||
(:core :scopes/core)
|
||||
(:client :scopes/web/client)
|
||||
(:message :scopes/core/message)
|
||||
(:server :scopes/web/server)
|
||||
(:t :scopes/testing))
|
||||
(:export #:run)
|
||||
|
@ -32,6 +33,7 @@
|
|||
(== (parse-integer (server:port cfg)) 8899)))
|
||||
|
||||
(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:send-request ctx nil) "Hello World!")))
|
||||
(== (client:get-page ctx msg) "Hello World!")))
|
||||
|
|
|
@ -3,19 +3,23 @@
|
|||
(defpackage :scopes/web/client
|
||||
(:use :common-lisp)
|
||||
(:local-nicknames (:config :scopes/config)
|
||||
(:core :scopes/core))
|
||||
(:export #:config #:base-url
|
||||
#:send-request))
|
||||
(:core :scopes/core)
|
||||
(:message :scopes/core/message))
|
||||
(:export #:config #:base-url #:api-path #:doc-path
|
||||
#:get-page))
|
||||
|
||||
(in-package :scopes/web/client)
|
||||
|
||||
(defclass config (config:base)
|
||||
((config:setup :initform #'core:default-setup)
|
||||
(base-url :reader base-url
|
||||
:initarg :base-url
|
||||
:initform "http://localhost:8135")))
|
||||
(base-url :reader base-url :initarg :base-url :initform "http://localhost:8135")
|
||||
(doc-path :reader doc-path :initarg :doc-path :initform "/")
|
||||
(api-path :reader api-path :initarg :api-path :initform "/api/")))
|
||||
|
||||
;;;; client context (= service)
|
||||
|
||||
(defun send-request (ctx msg)
|
||||
(dex:get (base-url (core:config ctx))))
|
||||
(defun get-page (ctx msg)
|
||||
(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)
|
||||
|
||||
(defun app (env)
|
||||
(print env)
|
||||
'(200 (:content-type "text/plain") ("Hello World!")))
|
||||
|
||||
(defun start (cfg)
|
||||
|
|
Loading…
Add table
Reference in a new issue