This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-17
Channels
- # announcements (24)
- # babashka (22)
- # beginners (49)
- # cider (16)
- # clj-kondo (8)
- # cljsrn (4)
- # clojure (87)
- # clojure-australia (7)
- # clojure-europe (44)
- # clojure-nl (4)
- # clojure-sweden (7)
- # clojure-uk (24)
- # clojurescript (5)
- # core-async (7)
- # cryogen (8)
- # cursive (22)
- # data-oriented-programming (2)
- # datomic (1)
- # emacs (6)
- # events (4)
- # fulcro (11)
- # google-cloud (1)
- # introduce-yourself (1)
- # java (8)
- # jobs (3)
- # lsp (10)
- # observability (1)
- # off-topic (12)
- # polylith (12)
- # re-frame (6)
- # reitit (36)
- # remote-jobs (1)
- # ring (4)
- # ring-swagger (1)
- # rum (4)
- # schema (1)
- # shadow-cljs (18)
- # sql (56)
- # tools-deps (33)
So :query
returns the same thing as :query-params
? I wonder if this a bug or intentional? From printing the reitit frontend navigate data:
#reitit.core.Match{:template "{*path}", :data {:name :delegate}, :result nil, :path-params {:path "/dannet/2022/search"}, :path "/dannet/2022/search", :query-params {:lemma "bygning"}, :parameters {:path {:path "/dannet/2022/search"}, :query {:lemma "bygning"}}}
Indeed, I believe :params
is from ring/wrap-params
if that is in the middleware stack somewhere.
Yes, but that is equivalent to any other query params map. Why go there anyway? Regularity
that still leaves me without a query string… it seems that some information is lost doesn’t it?
:query-string "id=10",
:remote-addr "127.0.0.1",
:request-method :get,
:scheme :http,
:server-name "localhost",
:server-port 8080,
:ssl-client-cert nil,
:uri "/api/query",
:muuntaja/request nil,
Sure I can concat it together, but why should I? The map has been parsed from the query string, not the other way around.
That just makes me do more work, when I just want to be able to access what was already there from the beginning.
So if I want to delegate a request from reitit’s frontend router to my backend I have to reconstruct the URL it from all of the parts rather than just pass it on. It’s more work and more error-prone.
Maybe my use case is just not what reitit wants to be. I only have
(def routes
[["{*path}" :delegate]])
and then I simply translate this to backend requests in my on-navigate
fn(sorry it this is a bit bitchy, but I just tracked down an annoying bug to reitit and I was surprised to find that there is no difference between :query
and :query-params
)
Hello everyone. Is it possible to constrain parameters? My frontend for example should match /users/:id/:tab
, if tab
is profile
or security
, but not if it's messages
, which should rendered by the backend with a full page load for the moment.
e.g.:
/users/1/profile
=> rendered by the SPA
/users/1/security
=> rendered by the SPA
/users/1/messages
=> rendered by the backend
Is it possible to have different coercions defined for :get and :post for the same path?
Ah, turns out I had only been using the shorthand of "func is automatically converted to {:handler func}". Thank you!
hi all - i’m pretty new to reitit (and clojure for that matter) and am trying to understand how to structure the data for a response that returns a map with a list of entities inside it. in this case “users” - my route is setup like this
["/users"
{:get {:summary "Get list of users for authorized caller"
:parameters {}
:responses {200
{:body domain/user-shape}}
:middleware [[collectivly-middleware/wrap-jwt]]
:handler handler/users-handler}
...SNIP....
and my user-shape is setup as data here
(def user-shape
{:id pos-int?
:first_name string?
:last_name string?
:image_url string?
:created_at inst?
:updated_at inst?
:user_xid. string?})
when using this approach for the /users/:id
route and setting the body response to be domain/user-shape
it works as expected. I’m not sure what the syntax is to represent this output for the responses
field.. ultimately the JSON response is:
{
users: [
{ "id": 1, "first_name": "mike", .... },
{ "id": 2, "first_name": "joe", ....}
]
}
It seems to me that your data returned is a collection of users, but your route expects to receive only a user. So it needs to be a coll-of
user-shape instead of the shape directly.
for the /users
GET route I’m getting a spec error
"spec": "(spec-tools.core/spec {:spec (clojure.spec.alpha/keys :req-un [:spec$40768/id :spec$40768/first_name :spec$40768/last_name :spec$40768/image_url :spec$40768/created_at :spec$40768/updated_at :spec$40768/user_xid]), :type :map, :leaf? false})",
"problems": [
{
"path": [],
"pred": "clojure.core/map?",