Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add header echoing server middleware #2024

Merged
merged 1 commit into from Aug 24, 2018
Merged

Conversation

@keirlawson
Copy link
Contributor

@keirlawson keirlawson commented Aug 20, 2018

A server middleware that echoes selected headers from request to response

Copy link
Member

@rossabaker rossabaker left a comment

Thanks! A couple open-ended questions and a strong suggestion, but I think this will be a nice addition.

* @param headerKeys the keys corresponding to the headers to echo on the response
* @param http [[HttpRoutes]] to transform
*/
def apply[F[_]: Functor](headerKeys: HeaderKey*)(http: HttpRoutes[F]): HttpRoutes[F] =

This comment has been minimized.

@rossabaker

rossabaker Aug 21, 2018
Member

This requires a HeaderKey, while Logger uses a redactHeadersWhen: CaseInsensitiveString => Boolean. There are pros and cons to both of those, but we should probably be consistent.

I might like the idea of a predicate. Then you could do things like _.startsWith("X-MyCompany-")

I think this could be generic in Http[F, G] instead of HttpRoutes[F] and then also work for HttpApp and future routing DSLs.

@keirlawson keirlawson force-pushed the keirlawson:headerecho branch from ec94e18 to 8c05924 Aug 21, 2018
@keirlawson
Copy link
Contributor Author

@keirlawson keirlawson commented Aug 21, 2018

As suggested, have moved to CaseInsensitiveString => Boolean for selecting headers and Http[F, G] rather than HttpRoutes[F]

@rossabaker
Copy link
Member

@rossabaker rossabaker commented Aug 21, 2018

Looks good. Just need to run test:scalafmt, and the build should pass.

@keirlawson keirlawson force-pushed the keirlawson:headerecho branch from 8c05924 to a47fcec Aug 21, 2018
@keirlawson
Copy link
Contributor Author

@keirlawson keirlawson commented Aug 21, 2018

Done

@rossabaker rossabaker merged commit fdb9678 into http4s:master Aug 24, 2018
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.