pedestal

simongray 2020-11-27T11:17:10.262600Z

I don’t think I quite understand error handling. According to http://Pedestal.io: > As long as there is an error attached to that key, Pedestal will not invoke the usual `:enter` and `:leave` functions. Instead, it looks for the next interceptor in the chain that has a `:error` function attached to it. So I would expect that throwing an exception in the :enter function would look for the exception handling Interceptor next in the queue. However, the behaviour actually seems to be the opposite: only Interceptors that come before the throwing Interceptor are considered.

simongray 2020-11-27T11:18:05.263300Z

I guess “the chain” really means “Interceptors that have been visited at least once”.

simongray 2020-11-27T11:18:25.263700Z

and then anything that comes after the throwing Interceptor is thrown out.

simongray 2020-11-27T11:22:11.264800Z

So should error handlers always be put at the very beginning of the Interceptors vector?

orestis 2020-11-27T11:41:50.265300Z

yes, a thrown exception AFAIK will terminate the queue and start unwinding

1👍
souenzzo 2020-11-27T11:43:45.266700Z

I found some tests with routing with :app-name // :host But I can't make it work. There is any sample app using this? (i prefer tabular routes once all my routes are tabular at this moment) https://github.com/pedestal/pedestal/blob/aa71a3a630dd21861c0682eeeebec762cbf3f85c/service/test/io/pedestal/http/route_test.clj#L285

2020-11-30T15:14:44.271100Z

@souenzzo by using vec you inadvertently switched routing syntax. FWIW, the docs do http://pedestal.io/reference/routing-quick-reference#_routes the relation between routing syntax and data structure type.

souenzzo 2020-11-27T11:44:58.266900Z

I'm trying with

::http/routes (vec (concat
                     (route/expand-routes red-green)
                     (route/expand-routes todo-list)))
It throws
Execution error (AssertionError) at io.pedestal.http.route.definition.terse/eval12443$fn (terse.clj:52).
Assert failed: Cannot expand '[:path "/red"]' as a route. Expected a verb map or path string, but found a class clojure.lang.MapEntry instead
false

souenzzo 2020-11-27T11:56:52.267200Z

OK, i should just concat, not vec concat

hlship 2020-11-27T16:57:41.267900Z

I'm trying a solution, an interceptor that sits early in the stack, and green-lists all the context and request keys (on enter) and uses select-keys on leave/error (obviously, also allowing :response).