如何将URL参数获取到Pedestal中的请求映射中?我假设这需要使用拦截器?然而,基座文件(或严重缺乏文件)并没有明确说明这一点。谢谢
查询参数由Pedal自动解析,生成的映射被放置在:query-params
键下的请求映射中。
作为一个简单的例子,从基座服务模板开始,并使用以下定义:
(defn home-page
[request]
(ring-resp/response (format "Hello with params: %s" (:query-params request))))
(defroutes routes
[[["/" {:get home-page}]]])
现在,如果您浏览到http://localhost:8080/?param=true&other=1234
,您应该会看到Hello world with paramters: {:param "true", :other "1234"}
。