Fork me on GitHub
#pedestal
<
2017-10-09
>
zallin10:10:56

how can multimethods serve as handlers ? annoyed wrapping them in functions 😣

souenzzo13:10:32

Multimethods are simple clojure functions, so yes, you can, but it need to receive request and return response

souenzzo13:10:09

And you may need to make some routes to it ["/foo" :get my-mm :route-name ::mm] ["/bar" :get my-mm :route-name ::mm*]

mtnygard13:10:26

@zallin You probably have to supply a route name in order to make the routes unique, too.

zallin13:10:47

when using mm as handler i get an error "You're trying to use something as an interceptor that isn't supported by the protocol; Perhaps you need to extend it?"

mtnygard13:10:36

Oh! That's interesting. I'd call that a bug. Would you be willing to file an issue?

zallin13:10:04

yes no problem

zallin13:10:32

will do later this evening

mtnygard13:10:50

Thank you.

mpenet14:10:21

is it possible to combine router instances? ex have a router based on map tree that contains a leaf with linear and another branch at some level using map tree?

mpenet14:10:49

just wondering, I don't really need this but I could see it used

mtnygard14:10:59

Routers are just interceptors

mtnygard14:10:11

So you can create a router then use it as an interceptor on another route

mpenet14:10:29

that's super cool

mpenet14:10:46

I must say that route lib is really impressive, probably deserves more attention

mpenet14:10:33

actually I have a use case for it now that I think of it: i might have to switch to linear router on some cases where there is ambiguity with other routers: ex /foo/:id/ followed by a /foo/bar/ route

mpenet14:10:02

trying to see if I can port what we have now over to pedestal/route

mtnygard14:10:34

Yeah, I’ve got a similar case. The API was defined and released long ago. So we’re kind of stuck with the linear router

mtnygard14:10:48

But so far the performance has been good enough that we didn’t get fancy

mpenet14:10:55

and to make it more difficult it's not on pedestal, we do use interceptors tho

mpenet14:10:48

another gem of a lib

mtnygard14:10:49

That’s interesting. I haven’t heard of anyone doing that before. What are you using to accept HTTP requests? And what are you using for routing now?

mpenet14:10:19

jetty 9 but we have a lot of internals that rely on old tricks and we do things differently with ws

mpenet14:10:34

ahh for routing: moved from clout to bidi recently

mpenet14:10:53

but bidi is a bit resource hungry it seems

mpenet14:10:07

and there are some bits I d prefer different

mtnygard14:10:43

So you write bidi handlers that call interceptor chains?

mpenet14:10:23

yes more or less. we have a resource abstraction that can load an interceptor chain and use it

mpenet14:10:33

we have doc & specs on top of it

mpenet14:10:43

a bit like yada, but somewhat different

mpenet14:10:55

response spec, request spec etc

mpenet14:10:55

I will have to play with the route mixing tomorrow, I hope this can be written in a somewhat declarative way without having to mess with interceptors too much

mtnygard14:10:49

Good luck. Let us know how it turns out

mpenet14:10:49

now that I think of it I could cheat with nginx

mpenet15:10:56

probably easier than nesting routers and whatnot. I would just rewrite/proxy the ambiguous routes to other paths that are resolvable with non linear routers without relying on ordering