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 WrappingResponseWriter interface #356

Merged
merged 2 commits into from
Nov 19, 2023

Conversation

stephenafamo
Copy link
Contributor

No description provided.

@aarondl
Copy link
Member

aarondl commented Nov 8, 2023

This doesn't seem necessary with the other PR that adds the standard interface implementation?

@stephenafamo
Copy link
Contributor Author

This one is necessary even with that.

The other pr (#350) makes the clientStateResponseWriter compatible with packages that need to inspect the underlying response writer.

This PR prevents a panic if the response writer was wrapped with a "Standard Library Wrapper" in between the ClientStateMiddleware and something that checks for it.

For example:

r := chi.NewRouter()

// loading the client state
r.Use(ab.LoadClientStateMiddleware)

// this will wrap the client state handler with an `UnwrappableResponseWriter`
r.Use(middleware.Logging)

// This will panic because it does not know how to unwrap the logging middleware
r.Use(ab.Middleware2(...)) 

@stephenafamo stephenafamo changed the title Add UnwrapableResponseWriter interface Add WrappingResponseWriter interface Nov 10, 2023
@aarondl aarondl merged commit 8fc0b1f into volatiletech:master Nov 19, 2023
2 checks passed
@stephenafamo stephenafamo deleted the unrwap-writer branch November 20, 2023 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants