reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
nivekuil 2020-10-14T05:07:54.120200Z

does reitit have any facilities for referring to path/query params within the route data structure itself?

nivekuil 2020-10-14T05:12:12.120300Z

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)

coby 2020-10-14T16:14:31.124200Z

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...

2020-10-14T20:48:51.124800Z

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!