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
|
// Create middleware that redirects to the appropriate provider logout
|
||||||
router.GET("/oauth/logout", Logout("/", opts.Basepath, allRoutes.AuthRoutes))
|
router.GET("/oauth/logout", Logout("/", opts.Basepath, allRoutes.AuthRoutes))
|
||||||
out = Logger(opts.Logger, PrefixedRedirect(auth))
|
out = Logger(opts.Logger, FlushingHandler(auth))
|
||||||
} else {
|
} else {
|
||||||
out = Logger(opts.Logger, PrefixedRedirect(router))
|
out = Logger(opts.Logger, FlushingHandler(router))
|
||||||
}
|
}
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
|
@ -4,28 +4,29 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
type interceptingResponseWriter struct {
|
type flushingResponseWriter struct {
|
||||||
http.ResponseWriter
|
http.ResponseWriter
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *interceptingResponseWriter) WriteHeader(status int) {
|
func (f *flushingResponseWriter) WriteHeader(status int) {
|
||||||
i.ResponseWriter.WriteHeader(status)
|
f.ResponseWriter.WriteHeader(status)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flush is here because the underlying HTTP chunked transfer response writer
|
// Flush is here because the underlying HTTP chunked transfer response writer
|
||||||
// to implement http.Flusher. Without it data is silently buffered. This
|
// to implement http.Flusher. Without it data is silently buffered. This
|
||||||
// was discovered when proxying kapacitor chunked logs.
|
// was discovered when proxying kapacitor chunked logs.
|
||||||
func (i *interceptingResponseWriter) Flush() {
|
func (f *flushingResponseWriter) Flush() {
|
||||||
if flusher, ok := i.ResponseWriter.(http.Flusher); ok {
|
if flusher, ok := f.ResponseWriter.(http.Flusher); ok {
|
||||||
flusher.Flush()
|
flusher.Flush()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrefixedRedirect alters the Location header of downstream http.Handlers
|
// FlushingHandler may not actually do anything, but it was ostensibly
|
||||||
// to include a specified prefix
|
// implemented to flush response writers that can be flushed for the
|
||||||
func PrefixedRedirect(next http.Handler) http.Handler {
|
// purposes in the comment above.
|
||||||
|
func FlushingHandler(next http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
iw := &interceptingResponseWriter{
|
iw := &flushingResponseWriter{
|
||||||
ResponseWriter: w,
|
ResponseWriter: w,
|
||||||
}
|
}
|
||||||
next.ServeHTTP(iw, r)
|
next.ServeHTTP(iw, r)
|
||||||
|
|
Loading…
Reference in New Issue