does reitit have any facilities for referring to path/query params within the route data structure itself?
in particular I'm trying to work with a fn
as data (part of route data), do something to it based off a query param, then call the fn
, without using eval
(seems to not really be a good option in cljs)
Getting 404s when requesting static assets in my super-basic throwaway project (playing around w/ Websockets/Sente):
(def app
(ring/ring-handler
(ring/router
[""
["/"
(fn [_]
{:status 200
:headers {"Content-Type" "text/html"}
:body (rum/render-static-markup [:html {:lang "en"}
[:head
[:title "Hello Websockets"]
[:meta {:charset "utf-8"}]
[:link {:rel "stylesheet" :href "/css/main.css"}]]
[:body
[:h1 "Hello Websockets"]
[:#app]
[:script {:src "/js/main.js"}]
[:script "ws.app.init()"]]])})]
["/chsk" {:get ring-ajax-get-or-ws-handshake
:post ring-ajax-post}]])
(ring/routes
(ring/create-resource-handler {:path "/" :root "public"})
(ring/create-default-handler
{:not-found (constantly {:status 404
:headers {"Content-Type" "textplain; charset=utf-8"}
:body "Not Found"})}))))
Here are my resources (minus CLJS noise) and some requests for them:
$ tree resources/ -I cljs-runtime
resources/
└── public
├── css
│ └── main.css
├── index.html
└── js
├── main.js
└── manifest.edn
3 directories, 4 files
$ curl localhost:8008/css/main.css
Not Found
$ curl localhost:8008/js/main.js
Not Found
Requesting /
works as expected, minus the subsequent resource requests failing of course... I feel like I'm missing something obvious...Hello everybody! I add a new Clojure implementation using Reitit on the website http://www.todobackend.com/. You can check the repo directly here: https://github.com/PrestanceDesign/todo-backend-clojure-reitit I think that can be useful. Cheers!