httpkit-fake 不拦截 url 使用传递的参数构建
httpkit-fake does not intercept url build with passed parameters
如何让 with-fake-http
拦截包含 :query-params
的 http/get
请求。以下代码产生异常
(require
'[org.httpkit.client :as http]
'[org.httpkit.fake :refer :all]
)
(with-fake-http ["localhost?q=hello" "hello param"]
(println @(http/get "localhost" :query-params {:q "hello"})))
CompilerException java.lang.IllegalArgumentException: Attempted to perform GET on unregistered URL localhost and real HTTP requests are disabled., compiling:(web/db_test.clj:57:1)
感谢您的帮助。
您可以提供包含键 :url
和 :query-params
的映射,而不是字符串 "localhost?q=hello"
(with-fake-http
[{:query-params {:q "hello"}, :url "localhost"} "hello param"]
(println @(http/get "localhost" {:query-params {:q "hello"}})))
如何让 with-fake-http
拦截包含 :query-params
的 http/get
请求。以下代码产生异常
(require
'[org.httpkit.client :as http]
'[org.httpkit.fake :refer :all]
)
(with-fake-http ["localhost?q=hello" "hello param"]
(println @(http/get "localhost" :query-params {:q "hello"})))
CompilerException java.lang.IllegalArgumentException: Attempted to perform GET on unregistered URL localhost and real HTTP requests are disabled., compiling:(web/db_test.clj:57:1)
感谢您的帮助。
您可以提供包含键 :url
和 :query-params
"localhost?q=hello"
(with-fake-http
[{:query-params {:q "hello"}, :url "localhost"} "hello param"]
(println @(http/get "localhost" {:query-params {:q "hello"}})))