reitit

valerauko 2024-08-23T09:36:51.731969Z

I need to deal with routes like the following

[["/api/items/:id"
  [".json" ::show]
  ["/details.json" ::details]]]
Is this possible with reitit?

valerauko 2024-08-23T09:37:55.354999Z

The above results in a multiple-terminators exception at compile-time

ikitommi 2024-08-23T10:30:51.595759Z

you need to revert to linear-router for that to work, e.g.

(def r
  (r/router
   ["/api/items/{id}"
    [".json" ::show]
    ["/details.json" ::details]]
   {:router r/linear-router}))

(r/routes r)
;[["/api/items/{id}.json" {:name :user/show}] 
; ["/api/items/{id}/details.json" {:name :user/details}]]

ikitommi 2024-08-23T10:31:34.369509Z

e.g. matches the routes from top-down, so they can be anything. First match wins.

ikitommi 2024-08-23T10:32:14.455889Z

just bit slower, that’s all.

ikitommi 2024-08-23T10:33:23.779829Z

also, I used the {} path parameter syntax here, more obvious where the path-parameter starts and ends. Should work with the normal : style too.

valerauko 2024-08-23T19:04:47.417539Z

Is there a way to mix routers? So like /api/items being a linear like you suggest but the rest being "default" (which i assume is more efficient)?