mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-24 17:28:31 +02:00
fix(middleware): skip modify response for websocket and event-stream requests in ServeHTTP
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
|||||||
"github.com/yusing/godoxy/internal/route/rules"
|
"github.com/yusing/godoxy/internal/route/rules"
|
||||||
"github.com/yusing/godoxy/internal/serialization"
|
"github.com/yusing/godoxy/internal/serialization"
|
||||||
gperr "github.com/yusing/goutils/errs"
|
gperr "github.com/yusing/goutils/errs"
|
||||||
|
"github.com/yusing/goutils/http/httpheaders"
|
||||||
"github.com/yusing/goutils/http/reverseproxy"
|
"github.com/yusing/goutils/http/reverseproxy"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -190,6 +191,11 @@ func (m *Middleware) ServeHTTP(next http.HandlerFunc, w http.ResponseWriter, r *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if httpheaders.IsWebsocket(r.Header) || r.Header.Get("Accept") == "text/event-stream" {
|
||||||
|
next(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if exec, ok := m.impl.(ResponseModifier); ok {
|
if exec, ok := m.impl.(ResponseModifier); ok {
|
||||||
rm := rules.NewResponseModifier(w)
|
rm := rules.NewResponseModifier(w)
|
||||||
defer rm.FlushRelease()
|
defer rm.FlushRelease()
|
||||||
|
|||||||
Reference in New Issue
Block a user