(Translated by https://www.hiragana.jp/)
Clojure record in route data is converted to a plain map · Issue #686 · metosin/reitit · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clojure record in route data is converted to a plain map #686

Closed
manderson202 opened this issue Jun 26, 2024 · 0 comments · Fixed by #687
Closed

Clojure record in route data is converted to a plain map #686

manderson202 opened this issue Jun 26, 2024 · 0 comments · Fixed by #687
Assignees
Labels

Comments

@manderson202
Copy link

manderson202 commented Jun 26, 2024

I have a route with some data on it where the value is a Clojure record. When I pass that route through reitit.ring/router it converts it to a regular map. This is on version 0.7.0

The source of the problem appears to be here. Perhaps a fix could be as simple as adding a condition prior to this line for record? and treating it as an opaque value without further de-structuring?

Reproducible example:

(defrecord FooTest [a b])
=> repl.FooTest

(reitit.core/match-by-path
 (reitit.ring/router
  ["/api/foo" {:get {:handler (constantly {:status 200})
                     :test (->FooTest 1 22)}}])
 "/api/foo")
=> #reitit.core.Match{:template "/api/foo", :data {:get {:handler #function[clojure.core/constantly/fn--5740], :test {:a 1, :b 22}}}, :result #reitit.ring.Methods{:get #reitit.ring.Endpoint{:data {:handler #function[clojure.core/constantly/fn--5740], :test {:a 1, :b 22}}, :handler #function[clojure.core/constantly/fn--5740], :path "/api/foo", :method :get, :middleware []}, :head nil, :post nil, :put nil, :delete nil, :connect nil, :options #reitit.ring.Endpoint{:data {:no-doc true, :handler #function[reitit.ring/fn--28003/fn--28012]}, :handler #function[reitit.ring/fn--28003/fn--28012], :path "/api/foo", :method :options, :middleware []}, :trace nil, :patch nil}, :path-params {}, :path "/api/foo"}

Note that :test in the output is a plain map and no longer a record.

@ikitommi ikitommi self-assigned this Jun 28, 2024
@ikitommi ikitommi added the bug label Jun 28, 2024
@ikitommi ikitommi mentioned this issue Jun 29, 2024
ikitommi added a commit that referenced this issue Jun 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants