Fork me on GitHub
#reitit
<
2019-02-18
>
ikitommi07:02:08

@colliderwriter I idea more. I think there could be just a generic wrapper that could be used to wrap the Sieppari-style error interceptors. e.g.

;; with Sieppari
:interceptors [(exceptions/exception-interceptor)]

;; with Pedestal
:interceptors [(reitit.pedestal/interceptor (exceptions/exception-interceptor))]
would that be possible? would be a generic solution for future too.

ikitommi07:02:06

and actually, the wrapping could automatic here: https://github.com/metosin/reitit/blob/master/modules/reitit-pedestal/src/reitit/pedestal.clj#L16. e.g. if the interceptor has :error of 1-arity…

ikitommi07:02:55

interceptors get compiled once, on router creation, so there is no runtime perf penalty, besides some interceptors having a extra wrapper.

levitanong09:02:48

hi all, is there a way to escape colons in a path? for dev, i’m running some server in a specific port, so i have something like "", but i’m running into some errors, and I realized the colon might be interpreted as a parameter.

levitanong09:02:52

Scratch that, it seems the problem is simply having a route parameter when the root isn’t /. Is there any particular reason why Routes must start from the root, so they must begin with a '/'?

ikitommi12:02:52

@levitanong that is a bad constraint from the past, should be removed

ikitommi12:02:20

Oh, but in Ring, all the uris should start with /?

ikitommi12:02:47

> :uri (Required, String) > The request URI, excluding the query string and the "?" separator. > Must start with "/".

levitanong17:02:50

@ikitommi i’m writing a server in nodejs though, so it’s not ring 😛 And besides, I see value in allowing non-“/”, in cases where you want your server to connect to an external resource as a client.

juhoteperi17:02:20

Not sure where the check currently is, or if there even is a check and reitit just doesn't work, but if there is a check, it should be moved to reitit-ring module. And I don't see how "cases where you want to server to connect to an external resource" relates to Reitit?

levitanong18:02:04

@juhoteperi i find it handy to use the reitit data structure to move routes to config. Consider the case where my group is developing both a set of microservices and a project that consumes these microservices. The project will have its own develop/staging/master deployments and likewise for the other microservices. Needless to say, we don’t want something in develop interacting with something in master. reitit helps me solve this problem by associating a URL with a route name. In my networking code, I can just worry about dealing with that route name, and assume the it will go to the right URL.

colliderwriter23:02:01

Is there a way to specify spec-coerced query parameters so they are optional? or to allow lists in body parameters? I get coercion errors

(s/def ::maybe-int? (s/or :int integer? :nil nil?))
(s/conform ::maybe-int? nil)
;;
(s/def ::vec-two-strings (s/cat :one string? :two string?) )
(s/conform  ::vec-two-strings '["tom" "sam"])