Fork me on GitHub
#ldnclj
<
2016-02-23
>
frankiesardo12:02:17

After my talk on pedestal back at Clojure Exchange quite a few people commented that they didn't want to try out Pedestal because it was an all-or-nothing framework.

frankiesardo12:02:36

Recently I've extracted the routing logic of pedestal in a self contained library that you can use with Ring and ClojureScript https://github.com/frankiesardo/tripod

frankiesardo12:02:51

I hope this can be your gateway drug to pedestal simple_smile

rickmoynihan14:02:56

@frankie: interesting! Does that mean route specific interceptors are supported on ring?

rickmoynihan14:02:48

(just read that it does)! But cool!

frankiesardo14:02:30

Ring doesn’t have to do anything, tripod returns a handler and it manages its own execution flow

frankiesardo14:02:01

This means you can use any existing middlewares globally and then apply specific interceptors as you define your routes.

rickmoynihan14:02:20

ok - so you're basically bypassing ring (except at the toplevel)

rickmoynihan14:02:46

makes sense - it probably can't be any other way

frankiesardo14:02:59

Mhmh, not really, it’s just an extra layer on top of ring, like compojure, but way more extensible

rickmoynihan15:02:47

yeah - that's basically what I meant... but what I suppose I mean is that interceptors replace some of the ring middlewares

rickmoynihan15:02:58

ring middlewares can be quite painful

rickmoynihan15:02:54

> On the frontend verbs make no sense. Out of interest what does this mean exactly?

frankiesardo15:02:47

That means that on clojurescript it does make no sense to define a map with {:get get-handler :put put-handler} because there are no verbs to route

rickmoynihan15:02:34

not an issue if you're not using clojurescript then simple_smile

frankiesardo15:02:05

it’s not an issue per se, it’s just a difference from the way pedestal defines route maps

rickmoynihan15:02:26

sure - I guess I mean is it doesn't concern me simple_smile

frankiesardo15:02:06

if you’re using ring with tripod your handler receives all the requests for all the verbs, it’s up to you what do you respond for a Get or a Put

frankiesardo15:02:20

(Liberator helps in this case)

rickmoynihan15:02:31

yeah liberator's pretty cool - but I remember reading somewhere that technically you should match VERBs before routes - can't remember why or where I read that... I know almost everyone seems to do it the other way though

frankiesardo15:02:02

If you match the route before the verb then your handler can still return 405 instead of 404, which is more correct

rickmoynihan15:02:37

interesting - I stand corrected - thanks! simple_smile

frankiesardo15:02:12

np if you try it out feedback is greatly appreciated :thumbsup:

rickmoynihan15:02:04

I've not used pedestal - but liked a lot of the ideas in it... especially route specific interceptors... So am definitely intersted in looking into it... Regarding interceptors - are there many available already? The advantage of middlewares is that there are a lot of them already written