Conversation
czechboy0
left a comment
There was a problem hiding this comment.
This is awesome - the logging middleware is a great example of a fully powerful middleware that also inspects individual body chunks. Though it does make it appear pretty complicated - I wonder if you could add (in a subsequent PR) a simpler middleware example that doesn't need to implement its own reader/writer, and only inspects the headers/trailers, so in theory should be much simpler.
| RequestReader.FinalElement == HTTPFields?, | ||
| ResponseWriter: ConcludingAsyncWriter & ~Copyable, | ||
| ResponseWriter.Underlying.WriteElement == UInt8, | ||
| ResponseWriter.FinalElement == HTTPFields? |
There was a problem hiding this comment.
These 6 constraints repeat in many places, should we provide two protocols, one for each tuple of 3, to make it more readable?
There was a problem hiding this comment.
Hm not sure if we want to introduce a separate protocol for this honestly. Not even sure if that would work since that protocol needs to inherit from the other protocol.
This PR adds an example showcasing how middleware can be used to intercept requests handled by a server. In detail, this PR adds a logging and request handling middleware. The logging middleware is capable of inspecting every single part of the request including the individual chunks read.
5ffce3f to
0761920
Compare
This PR adds an example showcasing how middleware can be used to intercept requests handled by a server and performed by a client. In detail, this PR adds a logging and request handling middleware. The logging middleware is capable of inspecting every single part of the request including the individual chunks read.