Fork me on GitHub
#pedestal
<
2019-07-18
>
Braden Shepherdson19:07:26

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?

Braden Shepherdson19:07:37

I can't actually find this in the docs, now that I'm looking for it.

donaldball19:07:23

You need io.pedestal.interceptor.chain/terminate

ddeaguiar19:07:30

For servlet-based services the termination impl is present and it checks for a :response key in the context

ddeaguiar19:07:13

if you are testing interceptors in isolation with an empty context then you need to add that

ddeaguiar19:07:15

I’d prefer that over calling io.pedestal.interceptor.chain/terminate if you are going to be sending back a response

Braden Shepherdson19:07:32

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.

ddeaguiar19:07:07

Ah yep, sorry about that. I should have double checked the source.

donaldball21:07:25

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?

ddeaguiar13:07:07

Hi @U04V4HWQ4, :strict-path-params? used to be less strict. For the full story see https://github.com/pedestal/pedestal/issues/572.

donaldball13:07:36

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

ddeaguiar13:07:33

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.

donaldball13:07:10

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.

donaldball13:07:14

M take is just that strict mode is doing two things that could and should be separated is all

Braden Shepherdson23:07:02

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.

ddeaguiar13:07:50

@UCY0GT0QM 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.

Braden Shepherdson13:07:33

Thanks, I appreciate it.