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
copy server logging middleware to client module #1820
Conversation
logBody: Boolean, | ||
redactHeadersWhen: CaseInsensitiveString => Boolean = Headers.SensitiveHeaders.contains | ||
)(client: Client[F]): Client[F] = | ||
Client.fromHttpService( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether this is the best approach here. It seems to work ok for low-volume clients but the to/from HttpService round-trip definitely adds some overhead. I'm also not sure how to implement this on master
, which has deprecated HttpService[F]
. I'd love suggestions on how to remove the HttpService[F]
interface from these client classes and just deal with Client[F]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems highly likely that a client will be based on either Http[Stream[F, ?], F]
or Http[Resource[F, ?], F]
in the future. And then the logging middleware can be built on Http[G, F]
and be unified for servers and clients.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice if we could share more code between the two implementations, but we have MiMa constraints to get this into release-0.18.x. I imagine a lot of the guts could be pulled out into core and then referred to in server and client. @ChristopherDavenport, does that seem worthwhile? You're the expert in this area.
logBody: Boolean, | ||
redactHeadersWhen: CaseInsensitiveString => Boolean = Headers.SensitiveHeaders.contains | ||
)(client: Client[F]): Client[F] = | ||
Client.fromHttpService( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems highly likely that a client will be based on either Http[Stream[F, ?], F]
or Http[Resource[F, ?], F]
in the future. And then the logging middleware can be built on Http[G, F]
and be unified for servers and clients.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is compliant for 0.18 I am all for it.
I think that message typeclass along with the Http changes make make a lot of sharing possible when this is advanced into the new branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, let's make it work here and let's make it prettier on master.
The copied files are mostly unchanged, except for updating the package name, running
scalafmt
, and changing the interface ofLogger.apply
to work better withClient[F]
.(Hopefully this is set up against the right base branch to be merged and released as part of the 0.18 series.)