Questions tagged [reitit]

Reitit is a fast data-driven router for Clojure(Script).

Examples

Simple route:

["/ping"]

Two routes:

[["/ping"]
 ["/pong"]]

Routes with route arguments:

[["/ping" ::ping]
 ["/pong" {:name ::pong}]]

Routes with path parameters:

[["/users/:user-id"]
 ["/api/:version/ping"]]
[["/users/{user-id}"]
 ["/files/file-{number}.pdf"]]

Route with catch-all parameter:

["/public/*path"]
["/public/{*path}"]

Full documentation is available here.

19 questions
8
votes
1 answer

How do I get Swagger UI to let me provide authentication header?

I used Luminus, along with reitit and swagger-ui to generate a page that lets me try out my Luminus API. I can just enter my API request body and submit to test my API. Now I have added authentication using buddy and my API requires a token to be…
Matt Lally
  • 435
  • 1
  • 3
  • 13
4
votes
1 answer

How to extract a path-param from a Reitit backend end route

How do you get a path-param out of a Reitit backend Clojure route? I am trying to get the val associated with :id in the following manner, but keep getting a 404 file not found error in the REPL. ["/foo/:id" {:get (fn [{:keys [path-params ]}] …
CambodianCoder
  • 467
  • 4
  • 14
3
votes
3 answers

How to define an optional query parameter with reitit clojure

I created an API using the following code: ["/environments/:env-name/nodes" {:swagger {:tags ["Nodes"]} :parameters {:path {:env-name ::vt-vali/name}}} ["" {:get {:summary "Retrieve the nodes from this environment" …
3
votes
0 answers

How to implement middleware for Swagger in compojure-api for converting schemas from kabab-case to camelCase

Application uses kabab-case key formatting for schema like below (s/defschema User {:first-name s/Str :last-name s/Str}) But for swagger docs I want the schema in camelCase like…
Abhishek Jaiswal
  • 628
  • 6
  • 17
2
votes
0 answers

Define reitit route segment as matching string or dynamic param as fallback

I am defining a nested router with reitit and I want to create a v2 of the api. Currently the api is attached at /something/ and I have routes defined for /something/ so when I try to add a route for /something/v2 it gets matched as if v2…
Billy Moon
  • 57,113
  • 24
  • 136
  • 237
2
votes
0 answers

Reitit not recognising a route when it is directly navigated to in browser

I am trying to define some routes to use on my website. I have them defined like so: (def routes ["/" ["" {:name :home :controllers [{:start (fn [& params] (js/console.log "Home")) :stop (fn [& params]…
Turmolt
  • 113
  • 9
2
votes
1 answer

How do you set up middleware in Clojure using Reitit to enable coercion of body params?

I am trying to set a a Reitit router that performs coercion. I can get the response section working but I can't seem to get the body coercion to work properly. The following is the code I am using: (ns example (:require [ring.middleware.json…
Zac Romero
  • 396
  • 3
  • 11
1
vote
1 answer

reitit.frontend - HTML5Router does not prevent anchor click as should on matching route

if we choose HTML5Router or Fragment router - in both cases reitit should prevent default anchor click behavior however, ignore-anchor-click function here is never…
1
vote
2 answers

avoid circular dependency when I access reitit route info from handler

Assuming I have some kind of router set up that maps some routes to handlers something like this... (ns myapp.user.api (:require [reitit.core :as r])) ; define handlers here... (def router (r/router [["/user" {:get {:name ::user-get-all …
Billy Moon
  • 57,113
  • 24
  • 136
  • 237
1
vote
0 answers

Where do you pass the :ignore-missing-mapping? keyword in reitit swagger to ignore unconvertable schemas?

I've been following the ring-swagger server.clj example to set my own http server but with prismatic/schema coercion. Everything works just fine when my leafs are of basic type such as s/Str or s/Int, but I can't get it to work with (s/pred…
D.Ginzbourg
  • 490
  • 7
  • 22
1
vote
1 answer

Use of undeclared var from a namespace, but the var exists

I have this def in myapp.core (core.cljs): (def router (reitit/router [["/" {:name :foo :view #'foo}]]) ) And in myapp.events (events.cljs), I use it like so: {:dispatch [:common/navigate (reitit/match-by-path myapp.core/router…
zendevil.eth
  • 974
  • 2
  • 9
  • 28
1
vote
1 answer

Why is a pound symbol required in my Reitit routes?

I have been making a personal site using ClojureScript and decided to go with Reitit as my routing library instead of my usual Secretary. I have read really good things about Reitit and have it sort of working, but it only will react when I navigate…
Turmolt
  • 113
  • 9
0
votes
1 answer

"Unsupported Context on :enter " when reitit interceptors are updated to async

I'm working on reitit http application which uses interceptors. Below is my code (ns ic.reitit-interceptor-multithreading) (require '[reitit.ring :as ring]) (require '[reitit.http :as http]) (require '[reitit.interceptor.sieppari :as…
user51
  • 8,843
  • 21
  • 79
  • 158
0
votes
3 answers

RIng with Coercion url parameter returning :status 500

This is my app: (def routes [["/api" ping-routes submissions-routes]]) (def app (ring/ring-handler (ring/router routes {:data {:coercion reitit.coercion.schema/coercion :muuntaja m/instance …
Harry
  • 3
  • 2
0
votes
0 answers

Layout component unable to render when Reitit router introduced

I'm having trouble sorting out why a layout/parent component (app.components.layout) is not resolving after a hard reload BUT is okay after a hot reload with dev server after I introduced routes. The error: TypeError: dapp.components.layout.render…
a11hard
  • 1,904
  • 4
  • 19
  • 41
1
2