pedestal

César Olea 2025-06-16T21:41:20.848099Z

I think I found a bug in the 0.8 version of pedestal regarding query parameters:

(response-for
    (hk/create-connector
      (-> (conn/default-connector-map 8080)
          (conn/with-routes
              #{["/query-params" :get
                 [(i/interceptor
                    {:enter
                     (fn [ctx]
                       (assoc ctx :response
                              {:status 200
                               :body {:query-string (get-in ctx [:request :query-string])
                                      :query-params (get-in ctx [:request :query-params])}}))
                     :name ::response-foo})]
                 :route-name ::query-params]}))
      nil) :get "/query-params?foo=bar")
  ;; => {:status 200,
  ;;     :body "{:query-string \"foo=bar\", :query-params nil}",
  ;;     :headers {:content-type "application/edn"}}
Query string is fine, but query params is nil. The same happens with a “real” request (i.e. not using response-for). It works as expected with pedestal 0.7 but not with either 0.8.0-beta-1 or 0.8.0-alpha-7.

👀 1
hlship 2025-06-17T15:32:45.506079Z

Parsing of query parameters is not intrinsic, it is behavior supplied by an interceptor. You get it for free with https://pedestal.io/api/0.8/io.pedestal.connector.html#var-with-default-interceptors or you need to add https://pedestal.io/api/0.8/io.pedestal.http.route.html#var-query-params explicitly.

César Olea 2025-06-17T16:13:59.364059Z

Of course you’re correct facepalm sorry for the noise.

hlship 2025-06-17T16:14:42.585309Z

I'm just glad I didn't screw up something basic. Keep up the testing and reporting, I love it!

❤️ 1