mvrilo / go-redoc

go-redoc is an embedded OpenAPI/Swagger documentation ui for Go using ReDoc
MIT License
66 stars 28 forks source link

Don't trigger superfluous logs #11

Closed grindlemire closed 5 months ago

grindlemire commented 6 months ago

When an http.ResponseWriter calls WriteHeader after calling Write it will log a statement to stderr: 2023/12/29 22:54:08 http: superfluous response.WriteHeader call from github.com/mvrilo/go-redoc.Redoc.Handler.func1 (redoc.go:96).

This is happening because the stdlib http code doesn't want the caller to set the response header after calling Write. This PR moves the call to WriteHeader above the Write call to prevent this log from being generated.

mvrilo commented 5 months ago

Nice, thanks @grindlemire!