Conversation
96b28bd to
7486a46
Compare
As noted in #63, an equivalent to Echo's `Skipper` would allow for middleware users to opt-out of validation in a more straightforward way. In a slightly different implementation to our `echo-middleware`, this does not allow the `Skipper` to consume the body of the original request, and instead duplicates it for the `Skipper`, and the other uses of it. Closes #63.
7486a46 to
ff1f0eb
Compare
|
@GreyXor how does this look? |
LGTM! :) |
| r2 := r.Clone(r.Context()) | ||
|
|
||
| if r.Body != nil { | ||
| bodyBytes, err := io.ReadAll(r.Body) |
There was a problem hiding this comment.
I have to think about this, because by reading the body, you are assuming that people aren't streaming a gigantic request. This choice has some memory usage and deserialization consequences.
I don't think we should copy the request, and pass the original request into the skipper. The user can decide whether or not to read the body; they may be able to decide if skipping is needed based on headers alone.
What do you think?
There was a problem hiding this comment.
This is new behaviour (that we don't have in i.e. echo-middleware), in a more defensive way than we've done previously
I'm happy leaving this logic out completely, and having it so if the Skipper is called and consumes the request body, it's up to the user to manage how to get the body in follow-up calls?
As noted in #63, an equivalent to Echo's
Skipperwould allow formiddleware users to opt-out of validation in a more straightforward way.
In a slightly different implementation to our
echo-middleware, thisdoes not allow the
Skipperto consume the body of the originalrequest, and instead duplicates it for the
Skipper, and the other usesof it.