I had it in my head that Pedestal stops processing interceptors once someone defines the :response
key. is that true? do I need to do something to configure that behavior?
I can't actually find this in the docs, now that I'm looking for it.
You need io.pedestal.interceptor.chain/terminate
For servlet-based services the termination impl is present and it checks for a :response
key in the context
if you are testing interceptors in isolation with an empty context then you need to add that
I’d prefer that over calling io.pedestal.interceptor.chain/terminate
if you are going to be sending back a response
ah, I figured out my problem, I think. it uses the ring response?
function, which requires that :headers
be a map. that wasn't always true in my code.
Ah yep, sorry about that. I should have double checked the source.
Hey, if you use :strict-path-params?
with url-for
, it throws on what seem to be a lot of false positives. Digging in a little bit, it seems that if your current route has path-params, and you do not dissoc them when calling url-for
on a route that does not use all of those path-params, pedestal will throw:
https://github.com/pedestal/pedestal/blob/aa71a3a630dd21861c0682eeeebec762cbf3f85c/route/src/io/pedestal/http/route.clj#L257-L258
I would fairly expect this to be a subset check, not an equality check. Is there a wrinkle I’m missing?
Hi @donaldball, :strict-path-params?
used to be less strict. For the full story see https://github.com/pedestal/pedestal/issues/572.
My take is that the combination of features here - that the path-params seems to default to those of the current route, and that strict mode throws on unexpected params - results in a strict mode that’s not usable in the general case. The only thing I want from a strict mode is validating that the params a route needs exist and are valid
Sorry this doesn’t seem to meet your needs. I’m not sure what you mean by not useable in the general case. If a path param is present on a route then the assumption is that it is needed. The current implementation of strict mode verifies this. Validation is a separate issue and is service specific. Service interceptors can handle that.
I mean that if you’re working on a traditional server-rendered html webapp, for example, and you’re in the context of a deeply nested resource (e.g. /org/:org-id/loc/:loc-id/zone/:zone-id
), and your navbar generates links to ancestor resources, you either can’t use strict mode, or you have to manually dissoc the extraneous params at every call site.
M take is just that strict mode is doing two things that could and should be separated is all
another oddity: the docs say that :params
is the combined :body-params
, :path-params
and :query-params
- I'm only using :path-params
and it isn't being set. I'm not sure what interceptor does that behavior, if it isn't just the docs being out of date.
@braden.shepherdson the docs are not correct, sorry you were caught by this. In general Pedestal abides by the following principle: If something is separate, keep it separate. If something can be customized via an interceptor, keep the base code as basic as possible I’ll create an issue in the pedestal.docs repo and update the docs.
Thanks, I appreciate it.
:thumbsup: