Rename PrefixedRedirect to FlushingHandler & comment
It's not clear whether this code is necessary, but investigating this was outside of the scope of this PR.pull/10616/head
parent
05128600c6
commit
ece512c631
|
@ -321,9 +321,9 @@ func NewMux(opts MuxOpts, service Service) http.Handler {
|
|||
|
||||
// Create middleware that redirects to the appropriate provider logout
|
||||
router.GET("/oauth/logout", Logout("/", opts.Basepath, allRoutes.AuthRoutes))
|
||||
out = Logger(opts.Logger, PrefixedRedirect(auth))
|
||||
out = Logger(opts.Logger, FlushingHandler(auth))
|
||||
} else {
|
||||
out = Logger(opts.Logger, PrefixedRedirect(router))
|
||||
out = Logger(opts.Logger, FlushingHandler(router))
|
||||
}
|
||||
|
||||
return out
|
||||
|
|
|
@ -4,28 +4,29 @@ import (
|
|||
"net/http"
|
||||
)
|
||||
|
||||
type interceptingResponseWriter struct {
|
||||
type flushingResponseWriter struct {
|
||||
http.ResponseWriter
|
||||
}
|
||||
|
||||
func (i *interceptingResponseWriter) WriteHeader(status int) {
|
||||
i.ResponseWriter.WriteHeader(status)
|
||||
func (f *flushingResponseWriter) WriteHeader(status int) {
|
||||
f.ResponseWriter.WriteHeader(status)
|
||||
}
|
||||
|
||||
// Flush is here because the underlying HTTP chunked transfer response writer
|
||||
// to implement http.Flusher. Without it data is silently buffered. This
|
||||
// was discovered when proxying kapacitor chunked logs.
|
||||
func (i *interceptingResponseWriter) Flush() {
|
||||
if flusher, ok := i.ResponseWriter.(http.Flusher); ok {
|
||||
func (f *flushingResponseWriter) Flush() {
|
||||
if flusher, ok := f.ResponseWriter.(http.Flusher); ok {
|
||||
flusher.Flush()
|
||||
}
|
||||
}
|
||||
|
||||
// PrefixedRedirect alters the Location header of downstream http.Handlers
|
||||
// to include a specified prefix
|
||||
func PrefixedRedirect(next http.Handler) http.Handler {
|
||||
// FlushingHandler may not actually do anything, but it was ostensibly
|
||||
// implemented to flush response writers that can be flushed for the
|
||||
// purposes in the comment above.
|
||||
func FlushingHandler(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
iw := &interceptingResponseWriter{
|
||||
iw := &flushingResponseWriter{
|
||||
ResponseWriter: w,
|
||||
}
|
||||
next.ServeHTTP(iw, r)
|
||||
|
|
Loading…
Reference in New Issue