Question: does your ring-session cookie change when returning from oauth?
So I've set up a ring handler via
(reitit.ring/ring-handler
(reitit.ring/router my-routes)
(reitit.ring.routes/create-file-handler {:root fs-root, :path "/"))
and I'm running into a problem where one of my routes (`/:foo/:bar`) is shadowing my static assets served via the file handler. Is there a way around this? I.e. can I get the static assets to have higher priority than this route? I can't really change either this route or the path of the static assets.Have a look at https://github.com/ring-clojure/ring/wiki/Creating-responses, I think you should be able to make a custom “static resource handler” fairly easily using ring.util.response
, and hopefully it would play nicely with your other routes.
Hmm yeah that looks like it could work.. although wouldn't that mean that we'd have to enumerate all the static files we're serving?
Not necessarily, you can still put wildcards in the path like with any other route, and then it’s up to your custom handler to take care of making sure the resource actually exists (and returning nil if it doesn’t).
Though I haven’t tried anything like that and I’m assuming reitit will move on to the next matching route if your handler returns nil (which is what compojure does).
I’d have to go back and dig thru the reitit docs to be sure.
or you could just try it and see if all your routes work right 😄
alright, I'll give that a shot, thanks 🙂
I actually have another issue as well: I'm using reitit.frontend.easy, and I have some routes serving static assets that it's currently picking up but that I would like it to ignore.
For instance, opening <http://my-backend/docs>
in my browser works (I get the static page), but clicking a link like <a href="/docs>Docs</a>
from a Reitit-controlled page doesn't — because Reitit intercepts the URL change so the static page never gets loaded.
How can I get around this?
...actually, I just saw that there's a :ignore-anchor-click?
option to reitit.frontend.easy/start!
that I think I should be using for this. I'll give that a shot now 🙂
Yup, that did the trick
Hello! I'm trying to make a basic swagger ui using reitit-swagger-ui but the webpage gives me an error and I just can't seem to figure out why. I'm generally copying from this project: https://github.com/metosin/reitit/blob/master/examples/ring-swagger/src/example/server.clj And the code is this:
(def app
(ring/ring-handler
(ring/router
[["/swagger.json"
{:get {:no-doc true
:swagger {:id "2.0"
:info {:title "my-api"
:description "something"}}
:handler (swagger/create-swagger-handler)}}]
["/api"
{:swagger {:id :my-api}}
["/checkImage"
{:post {:summary ""
:parameters {:multipart {:file multipart/temp-file-part}}
:responses {200 {:body {:errors true}}}
:swagger {:consumes ["image/jpg"]}
:handler checkImage}}]]]
{:data {:middleware [swagger/swagger-feature
multipart/multipart-middleware]}})
(ring/routes
(swagger-ui/create-swagger-ui-handler
{:path "/"})
(ring/create-default-handler))))
Okay I figured out that the problem was that I didn't have the correct middleware. However I believe it should be in the reitit docs which middlewares are required for these simple cases to work! (I'm actually not sure which middleware did the trick)