Fork me on GitHub
#pedestal
<
2019-09-17
>
ouvasam07:09:19

Hi, i have a problem with routes and i can't find the solution

ouvasam07:09:20

"/api" {:interceptors [http/transit-body] "/echo" {:get `api/echo} "/catalogues" {:get `[:catalogues api/get]} "/code-systems" {:get `[:code-systems api/get]} "/code-systems/formats" {:get `[:code-system-formats api/get]} "/code-systems/formats/:format" {:get `[:code-system-format api/get]} "/code-systems/:id" {:get `[:code-system-details api/get]} "/code-systems/:id/concepts" {:get `[:code-system-concepts api/get]} "/code-systems/:id/concepts/:id" {:get `[:code-system-concept-details api/get]}

ouvasam07:09:36

Why does "/code-systems/formats/:format" {:get `[:code-system-format api/get]} return 404 ?

orestis09:09:22

Reading from a phone, and lack of highlighting doesn’t help, but I don’t think you’re supposed to wrap :get [,,,] in a map. I’m surprised you don’t get an error.

orestis09:09:01

If you paste your entire routes definition it might be easier to catch.

ouvasam12:09:01

Hi @orestis and thanks for your response. I am new to pedestal and i can't find a way to make these routes working

ouvasam12:09:14

(def routes #{"/" {:get pages/home} "/health" {:get `api/health} "/app" {:interceptors [http/html-body] "" {:get `pages/spa}} "/api" {:interceptors [http/transit-body] "/echo" {:get `api/echo} "/catalogues" {:get `[:catalogues api/get]} "/code-systems" {:get `[:code-systems api/get]} "/code-systems/formats" {:get `[:code-system-formats api/get]} "/code-systems/formats/ATC" {:get `[:code-system-format api/get]} "/code-systems/:id" {:constraints {:id #"[0-9]+"} :get `[:code-system-details api/get]} ; "/code-systems/:id/concepts" {:get `[:code-system-concepts api/get]} ; "/code-systems/:id/concepts/:id" {:get `[:code-system-concept-details api/get]} "/user" {:get `api/user}}})

ouvasam12:09:22

(def service {;; do not block thread that starts web server ::http/join? false ::http/port port ::http/host "0.0.0.0" ::http/resource-path "/public" ::http/routes (route/expand-routes routes) ::http/enable-session {:cookie-name "SID" :store (cookie/cookie-store)} ::http/type :jetty ;; for dev only? ::http/secure-headers {:content-security-policy-settings {:object-src "none"}} ::http/container-options {:h2c? true :h2? false :ssl? false}})

ouvasam12:09:18

i did try to change to sopmething like this

ouvasam12:09:20

(def routes [[["/" :get pages/home ["/app" {:get pages/spa} ^:interceptors [http/html-body]]]]])

ouvasam12:09:26

but i have this error

gerred12:09:32

there's a snippets feature in Slack if you click the paperclip, like this:

ouvasam12:09:34

Caused by: java.lang.IllegalArgumentException: No implementation of method: :expand-verb-action of protocol: #'io.pedestal.http.route.definition.terse/ExpandableVerbAction found for class: app.html_pages$spa

gerred12:09:50

there you go 🙂

gerred12:09:58

now it's expandable and has code highlighting.

ouvasam12:09:13

thanks and sorry for that

gerred12:09:20

no worries if you didn't know you didn't know. 🙂

ouvasam13:09:40

Even with this new routes, last route does not work (api/code-systems/formats/test1) -> 404 not found

orestis14:09:00

That is a weird route syntax. I’m only familiar with the table syntax...

orestis14:09:57

http://pedestal.io/reference/routing-quick-reference - doesn’t seem to be a need to quote the vector as you do?

ouvasam14:09:53

If i don't quote i haave error like Caused by: java.lang.IllegalArgumentException: No implementation of method: :expand-verb-action of protocol: #'io.pedestal.http.route.definition.terse/ExpandableVerbAction found for class: app.html_pages$spa

ouvasam14:09:04

But i think i'll go with reitit ring. There is not so much documentation on pedestal and i am not able to understand via the api documentation. Many thanks @orestis

orestis14:09:53

I won’t blame you — I’ve only used the table syntax because it’s the only one that made some sense. The syntax you’re using looks very fiddly to get right.