Look at other middleware for inspiration
Let's look at other languages and see what we're missing. Many of them are trivial, and it's a great way to make a first contribution to the project. If you see one that you'd like, add it here. And better yet, grab it. We're here to help.
- Ruby
- Haskell and more Haskell
Would there be interest in something like a ResponseTimer middleware, similar to express.js' response-time? Could use cats' Clock.
Would this be different than the existing Prometheus Metrics and Dropwizard Metrics integrations? Also see #2131, for making a common metrics implementation with library-specific interpreters.
Oh nice! I think my intention would be another "Simple middleware" like HeaderEcho for basic timing info without external metrics integrations. If those metrics are sufficient, I can look into other middleware to add.
You mean like a middleware that returns an X-Response-Time header? I think this might be possible after #2131: instead of writing to a metrics backend, produce a header.
Yep, just tacking on an X-Response-Time header was what I was thinking. If that's covered with the MetricsOps refactor, then that's great, but on first glance it looked like most of that work was on the client.
The existing work has been on the client. The other ticket is to do similar for the server. Since the MetricsOps operations return F[Unit], I'm not sure it would work for a response header.
Just peeked at the server metrics PR #2173, and the common MetricsOps return F[Unit] which is great for writing to a registry, but not a response header -- like you said.
Do you think it's worth it to put up a PR of a simple middleware for adding an X-Response-Time header?
I'm open to it. One thing we struggled with on the server metrics: is response time the time until the header, or time until the entire response body is created? Both can be useful. You'll want to make clear what's being measured.
Sounds good! I remember seeing that in the metrics PR too.
@rossabaker would you be interested in a Http Method Overrider middleware (kinda like the Python's Django one)?
@nebtrx Yes, that has proven useful in other languages.
@nebtrx Yes, that has proven useful in other languages.
Cool! I just pushed a PR with that purpose. Please take a look at it and let me know how it goes.
We got a couple out of this. I think it's served its purpose, but please don't hesitate to bring more useful ones.