pedestal

2019-09-17T07:24:19.000600Z

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

2019-09-17T07:24:20.000800Z

"/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]}

2019-09-17T07:24:36.001200Z

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

orestis 2019-09-17T09:26:22.002900Z

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.

orestis 2019-09-17T09:27:01.003600Z

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

2019-09-17T12:51:01.004300Z

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

2019-09-17T12:51:14.004500Z

(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}}})

2019-09-17T12:51:22.004700Z

(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}})

2019-09-17T12:52:18.005300Z

i did try to change to sopmething like this

2019-09-17T12:52:20.005500Z

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

2019-09-17T12:52:26.005900Z

but i have this error

2019-09-17T12:52:26.006Z

@ouvasam

2019-09-17T12:52:32.006300Z

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

2019-09-17T12:52:34.006500Z

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

2019-09-17T12:52:41.006700Z

Ok sorry

2019-09-17T12:52:48.006800Z

2019-09-17T12:52:50.007300Z

there you go 🙂

2019-09-17T12:52:58.007500Z

now it's expandable and has code highlighting.

2019-09-17T12:53:13.008Z

thanks and sorry for that

2019-09-17T12:53:20.008300Z

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

2019-09-17T13:24:40.008700Z

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

orestis 2019-09-17T14:32:00.009800Z

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

orestis 2019-09-17T14:35:57.010500Z

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

2019-09-17T14:43:53.011100Z

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

2019-09-17T14:45:04.012400Z

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

orestis 2019-09-17T14:52:53.013Z

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.