pedestal

hlship 2024-04-05T18:44:20.928259Z

This observer thing is coming along very nicely. PR later today. Here's a preview:

DEBUG io.pedestal.interceptor.chain.debug - {:interceptor :io.pedestal.interceptor.observer-test/handler, :stage :enter, :execution-id 2, :context-changes {:added {[:response] {:status 200, :body ...}}}, :line 119}
DEBUG io.pedestal.interceptor.chain.debug - {:interceptor :io.pedestal.interceptor.observer-test/content-type, :stage :leave, :execution-id 2, :context-changes {:added {[:response :headers] {"Content-Type" "application/edn"}}}, :line 119}
I wrote a little code to identify the changes in two maps in terms of key paths. It also has an "omit set" of key paths to be replaced with ... so that you don't spew out request and response bodies to logging (because they are large and possibly sensitive). This is going to be very useful.

ghadi 2024-04-05T19:14:04.718169Z

seems like a performance crater

ghadi 2024-04-05T19:16:06.849609Z

spewing to log is a choice, but I prefer tapping in/out and being in charge of whether I log, use morse, how to diff, etc.

hlship 2024-04-05T19:41:52.625459Z

It's intended for local development.

hlship 2024-04-05T19:42:21.292639Z

So the base abstraction is the observer function; the sample above is one particular way to use that abstraction.

hlship 2024-04-05T19:42:22.408479Z

https://github.com/pedestal/pedestal/pull/836

hlship 2024-04-05T19:43:50.221789Z

But I like the idea of tap>-ing the result.

hlship 2024-04-05T19:47:24.312479Z

I've torn my hair out before trying to figure out which interceptor made what change to the context, so I'm really looking forward to using this!

hlship 2024-04-05T19:51:29.943209Z

You could literally (chain/add-observer context tap>).

hlship 2024-04-05T21:06:07.502339Z

I've hooked it up to the embedded template:

DEBUG io.pedestal.interceptor.chain.debug - {:interceptor :io.pedestal.http.cors/dev-allow-origin, :stage :enter, :execution-id 1, :context-changes {:added {[:request :headers "origin"] ""}}, :line 128}
DEBUG io.pedestal.interceptor.chain.debug - {:interceptor :io.pedestal.http.tracing/tracing, :stage :enter, :execution-id 1, :context-changes {:added {[:bindings] ..., [:io.pedestal.http.tracing/otel-context-cleanup] ..., [:io.pedestal.http.tracing/prior-otel-context] ..., [:io.pedestal.http.tracing/otel-context] ..., [:io.pedestal.http.tracing/span] ...}}, :line 128}
DEBUG io.pedestal.interceptor.chain.debug - {:interceptor :io.pedestal.http/log-request, :stage :enter, :execution-id 1, :context-changes nil, :line 128}
DEBUG io.pedestal.interceptor.chain.debug - {:interceptor :io.pedestal.http.route/query-params, :stage :enter, :execution-id 1, :context-changes nil, :line 128}
DEBUG io.pedestal.interceptor.chain.debug - {:interceptor :io.pedestal.http.route/method-param, :stage :enter, :execution-id 1, :context-changes nil, :line 128}
DEBUG io.pedestal.interceptor.chain.debug - {:interceptor :io.pedestal.http.ring-middlewares/resource, :stage :enter, :execution-id 1, :context-changes nil, :line 128}
DEBUG io.pedestal.interceptor.chain.debug - {:interceptor :io.pedestal.http.route/router, :stage :enter, :execution-id 1, :context-changes {:added {[:request :url-for] ..., [:request :path-params] [], [:route] ..., [:url-for] ...}, :changed {[:bindings] ..., [:io.pedestal.interceptor.chain/queue] ...}}, :line 128}
DEBUG io.pedestal.interceptor.chain.debug - {:interceptor :io.pedestal.http.route/path-params-decoder, :stage :enter, :execution-id 1, :context-changes {:changed {[:request :path-params] {:from [], :to {}}}, :added {[:io.pedestal.http.route/path-params-decoded?] true}}, :line 128}
DEBUG io.pedestal.interceptor.chain.debug - {:interceptor "#Interceptor{}", :stage :enter, :execution-id 1, :context-changes {:added {[:response] {:status 200, :body ...}}}, :line 128}
DEBUG io.pedestal.interceptor.chain.debug - {:interceptor :io.pedestal.http.secure-headers/secure-headers, :stage :leave, :execution-id 1, :context-changes {:added {[:response :headers] {"Strict-Transport-Security" "max-age=31536000; includeSubdomains", "X-Frame-Options" "DENY", "X-Content-Type-Options" "nosniff", "X-XSS-Protection" "1; mode=block", "X-Download-Options" "noopen", "X-Permitted-Cross-Domain-Policies" "none", "Content-Security-Policy" "object-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' 'strict-dynamic' https: http:;"}}}, :line 128}
DEBUG io.pedestal.interceptor.chain.debug - {:interceptor :io.pedestal.http.ring-middlewares/content-type-interceptor, :stage :leave, :execution-id 1, :context-changes nil, :line 128}
DEBUG io.pedestal.interceptor.chain.debug - {:interceptor :io.pedestal.http/not-found, :stage :leave, :execution-id 1, :context-changes nil, :line 128}
DEBUG io.pedestal.interceptor.chain.debug - {:interceptor :io.pedestal.http.tracing/tracing, :stage :leave, :execution-id 1, :context-changes {:changed {[:bindings] ...}, :removed {[:io.pedestal.http.tracing/otel-context-cleanup] ..., [:io.pedestal.http.tracing/prior-otel-context] ..., [:io.pedestal.http.tracing/otel-context] ..., [:io.pedestal.http.tracing/span] ...}}, :line 128}
DEBUG io.pedestal.interceptor.chain.debug - {:interceptor :io.pedestal.http.impl.servlet-interceptor/ring-response, :stage :leave, :execution-id 1, :context-changes nil, :line 128}
DEBUG io.pedestal.interceptor.chain.debug - {:interceptor :io.pedestal.http.impl.servlet-interceptor/stylobate, :stage :leave, :execution-id 1, :context-changes nil, :line 128}
Looks like there's a little bug in the :io.pedestal.http.route/router interceptor and the :[:request path-params] key, no?

hlship 2024-04-05T23:15:40.495709Z

0.7.0-beta-1 ... just saying.

🚀 3
🎉 9
rossputin 2024-04-27T20:01:20.654719Z

hey, any details on how? I think this is/will affect me, thanks

rossputin 2024-04-29T08:28:04.094989Z

I’m currently thinking my own issues are sort of related but more about me updating openjdk and clojure on my guix system at the moment - either way… with my local project dependencies identical to before openjdk and clojure updates have led to some weird dependency issues with Jetty for the most part - I’ll confirm when I have time)

hlship 2024-04-28T20:32:13.034549Z

It’s on my todo list. Thanks for jogging my memory.

hlship 2024-04-28T20:32:26.106709Z

It’ll take a new release of lacinia-pedestal to make it work.

2024-04-06T13:52:11.362449Z

Can I try this out now in my lacinia-pedestal app, or do I need to wait for lacinia-pedestal to be updated too?

hlship 2024-04-06T15:45:37.690999Z

I can’t think of a reason that would prevent them from working together.

hlship 2024-04-06T22:13:55.171859Z

Which is to say, there’s only a few non-backwards compatible changes, and I don’t believe that any of those overlap with anything lacinia-pedestal uses.

2024-04-06T22:32:16.429599Z

lacinia-pedestal uses io.pedestal.http.jetty.websockets which was renamed

hlship 2024-04-07T03:42:28.822819Z

Ah, then my memory is not good. I’ll have to look into that.