Fork me on GitHub
#reitit
<
2022-04-11
>
robert-stuttaford07:04:08

https://cljdoc.org/d/metosin/reitit/0.5.18/doc/ring/ring-router#reititringring-handler has the match being placed in the request under :reitit.core/match. however, there's no indication of which handler is being called - :get, :post, etc. - in the match data that is put there. does this mean that i'm expected to inspect the request's :request-method myself, or is it perhaps an oversight that the match doesn't include this info?

juhoteperi07:04:16

The impl uses request-method. The route match happens first without considering request-method, then the reitit ring adapter checks if the match has a handler fn for that method. https://github.com/metosin/reitit/blob/master/modules/reitit-ring/src/reitit/ring.cljc#L324-L327

robert-stuttaford07:04:35

ok great, so basically this injection of the match happens before the request-method stuff is dealt with, cool

robert-stuttaford07:04:52

thanks for the quick response!

juhoteperi07:04:00

I think the injection still happens after this (the next line), but the match data was constructed without considering the method. There isn't a reason why method couldn't be added to match, but I guess it just wasn't considered as the reitit-core version doesn't know anything about method anyway.

Tanel08:04:20

I get this error after upgrading from reitit 0.5.2 to 0.5.18, any advice?

Tanel09:04:01

0.5.15 works, but 0.5.16 breaks with this error. Seems to be swagger ui related

byrongibby20:04:24

Hi. This PUT request throws a null pointer exception, and I can't figure out why?

:put {:tags ["Data set"]
      :summary "Update data set"
      :parameters {:path :econdata.utilities.spec/datasets-path-params
                   :multipart {:file multipart/temp-file-part}}
      :handler (constantly {:status 200})}

byrongibby20:04:23

Changing the method to a POST request returns status 200 OK

byrongibby20:04:38

I am using the latest Reitit

wevrem20:04:33

I don’t know off the top of my head, but some questions I would ask myself are: (1) what middleware is being used? (2) what are the different ways that POST and PUT are handled by reitit and/or the middleware, for example, is there an expectation of a :body that is not being supplied, producing the null pointer exception? Those are some things I would check. Good luck!

👍 1
byrongibby20:04:15

Thanks I will definitely try your advice

byrongibby21:04:39

You were spot on, it was a custom middleware I had written that was misbehaving. Thanks for the help. A false clue led me to waste hours on what should have been a simple fix T_T