Hi, I'm using pedestal for a new project.
I have an endpoint /indicators/:id and another one /indicators/search but the search endpoint doesn't get hit because it gets inferred as an :id when using the #{set} syntax. What is the correct approach?
(defn routes [db]
#{;lookup by indicator id
["/indicators/:id" :get [(db-interceptor db) indicator-handler] :route-name :get-indicator]
;search uses :id since #{clojure set} doesn't guarantee matching order
["/indicators/:id" :post [(body-params/body-params) (db-interceptor db) indicator-handler] :route-name :post-indicator]
...
I would like the second line [POST] to read "/indicators/search" but if I do it that way I get Not Found instead of actual results. Which is confusing, I would think it would match according to HTTP Method and then the route name/wording. Anyway, I think this is because I'm using #{set} syntax?Apparently pedestal matches to Path first and then Method, is there an easy way to convert my routes to table or vector routing?
Which version of Pedestal are you using?
[io.pedestal/pedestal.service "0.6.3"] [io.pedestal/pedestal.route "0.6.1"] [io.pedestal/pedestal.jetty "0.6.3"]
should be on 7.2?
First off, the latest stable version of Pedestal is 0.7.2. Routing is a bit more complex than you might think, and has been worked on extensively in 0.8. I think there is more to this than the snippets you've shown, as routes with the same path are absolutely differentiated by method.
If I make two separate paths /indicators/:id and /indicators/search the set assumes that search is an :id so I think I need to use the vector format?
When you have both ["/indicators/:id" :get ...] and ["/indicators/search" :get ...] that's a bit of a conflict and is handled in different ways in different versions of Pedestal.
In 0.7.2, you would directly invoke the table/table-routes function, rather than use the set syntax, so that you can put the routes in a specific order, and use the linear router.
In 0.8.0, you would do nothing because the default router, Sawtooth, handles this case correctly; it does not consider it a conflict.
Hm that's cool, I will try 8.0-beta-1 then
It's quite stable for a beta. I don't see a lot of distance between where the code is now and the final release.
Nice. I got it working with 8.0-beta-1 although I get a lot of deprecation warnings in the console for the code I'm using, but that's livable
See https://clojurians.slack.com/archives/C0K65B20P/p1750666855692939
Thanks!
Help Wanted
Pedestal includes the embedded template for use with deps-new; it's in the documentation and it's quite handy.
However, it includes a simple index.html file that is unstyled and ugly. I would like a very simple index.html and app.css that makes for a prettier page. Absolutely not anything elaborate, just something that will looks nice and say 'we put some effort into this" and include the Pedestal logo; something that echos the https://pedestal.io 's overall look.
Again, I'm thinking something that will likely be thrown away, just a few lines of HTML and CSS.
Any volunteers with basic HTML/CSS skills?
I got an error when signing the CLA (twice).. but I've opened a PR, so feel free to clone it, add it under your name and close my PR 👍
Thanks for the effort, I’ll look into why the CLA app is failing when I get to the office
What about this? I can adapt it to whatever you prefer and open a PR..
Have you signed the CLA? A PR where this is added to the embedded template would be quite welcome!
Looks nice