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.
I guess “the chain” really means “Interceptors that have been visited at least once”.
and then anything that comes after the throwing Interceptor is thrown out.
So should error handlers always be put at the very beginning of the Interceptors vector?
yes, a thrown exception AFAIK will terminate the queue and start unwinding
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
@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.
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
OK, i should just concat, not vec concat
https://gist.github.com/souenzzo/84851560aefb2e919e293996d3c9f1ff