Hi
has anyone integrated buddy access rules with reitit
i would like to know whats the best way of doing it because it seems to me i could somehow define the access rule in the route itself
instead of having a separate function.
Im currently doing it before the router with a middleware
(def rules
[{:uri "/api/user/*"
:handler authenticated-or-preflight?}
{:uri "/api/identity"
:handler authenticated-or-preflight?}])
(defn on-error
[request value]
{:status 403
:headers {
"Content-Type" "text"
}
:body "Not authorized"})
(defn my-authfn
[__ token]
(session-store/get-user-from-store token))
(def backend (backends/token {:authfn my-authfn}))
(defn wrap-base [handler]
(-> ((:middleware defaults) handler)
(wrap-access-rules {:rules rules :on-error on-error})
;(wrap-authorization auth-backend)
(wrap-authentication backend)
I was wondering if there is a way i could define it in the route itself using a reitit middlware
disregard
found an example of what i was looking here https://github.com/lipas-liikuntapaikat/lipas
Is there any way to have routes in reitit that are on the same level in the hierarchy?
I’d like to be able to have /word/add and /word/1 for the URI, but reitit is telling me it’s not allowed
@emil0r just add :conflicts nil
.
In the router options itself?
reitit will use linear router and match the first one. for router options
the exception should have that info in the message
Cool. works
https://cljdoc.org/d/metosin/reitit/0.5.2/doc/basics/route-conflicts
Mostly needed it for breadcrumbs so that I can easily decide a hierarchal structure
Hmm… I really need to learn to look for cljdoc. I’m too used to readme’s
Hi all, quick question. Is there an idiomatic way to do route restrictions on the front end? For the moment, I am designating some routes as public
in my routes and then my router component, is filtering in/out the public routes.