This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-09
Channels
- # announcements (1)
- # aws (4)
- # beginners (55)
- # calva (13)
- # cider (58)
- # clj-kondo (59)
- # cljs-dev (4)
- # clojure (21)
- # clojure-austin (1)
- # clojure-dev (2)
- # clojure-europe (4)
- # clojure-italy (9)
- # clojure-nl (13)
- # clojure-norway (4)
- # clojure-spec (12)
- # clojure-uk (15)
- # clojurescript (22)
- # cursive (11)
- # datomic (3)
- # duct (1)
- # events (1)
- # fulcro (6)
- # graalvm (28)
- # hoplon (9)
- # jobs (2)
- # jobs-discuss (21)
- # mount (14)
- # nrepl (4)
- # off-topic (38)
- # pathom (1)
- # perun (4)
- # re-frame (17)
- # reitit (32)
- # shadow-cljs (44)
- # testing (7)
- # tools-deps (62)
- # vim (10)
@grzegorzrynkowski_clo mw are applied in the order they are defined, and the order can matter. For example, the content-negotiation needs to happen before request or response formatting.
mw could be reordered automatically based on their requirements, there is a helpers to build such a dependency system.
@ikitommi re the mw order:
1. in this case, shouldn’t parameters parameters/parameters-middleware
in the ring-spec-swagger example be listed later in the vector (after the muuntaja entries)? (https://github.com/metosin/reitit/blob/master/examples/ring-spec-swagger/src/example/server.clj#L88)
2. Since the exception-middleware
doesn’t react on requests directly (but in response to handlers or middlewares error), shouldn’t it be first in the vector of middlewares? (https://github.com/metosin/reitit/blob/master/examples/ring-spec-swagger/src/example/server.clj#L94)?
@grzegorzrynkowski_clo the parameters-middleware
is from ring and doing it's own negotiation for form parameters, so it can be in that place. There is an issue to move that too to Muuntaja (and multiparts too), do all negotiations would be in one place.
it needs to be before request-coercion, which expects raw parameter maps to exist in the request
have you tried the mw chain debugger? It shows what different components are doing for req/res
Yes, I tried now, great tool. Thanks
are there any examples of using reitit to handle routes for a client side http library? would such a thing work?
@ramblurr sure: https://github.com/metosin/reitit/tree/master/examples/frontend and others from the examples folder.
@rgm that's not quite what I mean. That's for frontend routing in the browser, which is essentially the same concept as backend routing in a rest api. What I'm pondering is using reitit as the framework to build up a library for interacting with an existing HTTP API. Somehow using reitit defined routes to generate request maps to be passed to clj-http
There’s an href generator in frontend.easy ... do you mean something like that? https://github.com/metosin/reitit/blob/master/examples/frontend-re-frame/src/cljs/frontend_re_frame/core.cljs
@ramblurr would you use reitit on the client side to describe paths in any server or a just for a reitit backend?
for a reitit backend, you can use shared routes. For more dynamic system, this could be useful: https://github.com/metosin/reitit/issues/227
for full integration, all the information (parameters, auth) should be exposed. Swagger is providing one such tool...
In this particular case it would be to describe paths of a non-reitit backend. However for other scenarios we have, using it against a reitit backend would also be useful
for this particular task I'm working on, I have a rather large and complicated third-party http api, and I want to define it as data, then be able to operate on it with param coercion.
sounds good, you should be able to build such a (data-driven) client with reitit. Just build on top of the core router + coercion.
... and can use middleware or interceptors too in the client side, just like clj-http
does
if the legacy app already does swagger/openapi, you could use something like Martian (https://github.com/oliyh/martian).
oh martian is interesting! thanks for that link. unfortunately this service doesn't have a swagger definition, but that would come in handy
one reason for us tl start developing malli (https://github.com/metosin/malli) is to be able to serialize data model definitions over the wire: here, servers could expose all their route info to clients, which could mock those locally, generate uis etc