pedestal

2019-07-18T19:06:26.075400Z

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?

2019-07-18T19:06:37.075700Z

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

donaldball 2019-07-18T19:07:23.076100Z

You need io.pedestal.interceptor.chain/terminate

2019-07-18T19:14:30.076800Z

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

2019-07-18T19:15:13.077200Z

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

2019-07-18T19:16:15.077900Z

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

2019-07-18T19:52:32.078600Z

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.

2019-07-18T19:59:07.079100Z

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

donaldball 2019-07-18T21:41:25.081100Z

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?

2019-07-19T13:18:07.083100Z

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

donaldball 2019-07-19T13:23:36.083400Z

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

2019-07-19T13:40:33.083600Z

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.

donaldball 2019-07-19T13:50:10.089200Z

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.

donaldball 2019-07-19T13:52:14.089400Z

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

2019-07-18T23:31:02.082200Z

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.

2019-07-19T13:45:50.084200Z

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

2019-07-19T13:46:33.084800Z

Thanks, I appreciate it.

2019-07-19T13:46:42.085300Z

:thumbsup: