fix: WS upgrade via metrics middleware (realtime), DM names, tap reactions
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"net"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -82,6 +85,23 @@ func (r *recorder) WriteHeader(code int) {
|
||||
r.ResponseWriter.WriteHeader(code)
|
||||
}
|
||||
|
||||
// Hijack forwards the WebSocket upgrade to the underlying writer. Without
|
||||
// this, wrapping the mux breaks every WebSocket handshake.
|
||||
func (r *recorder) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
||||
hj, ok := r.ResponseWriter.(http.Hijacker)
|
||||
if !ok {
|
||||
return nil, nil, errors.New("metrics: response writer does not support hijacking")
|
||||
}
|
||||
return hj.Hijack()
|
||||
}
|
||||
|
||||
// Flush forwards periodic flush calls for streaming responses.
|
||||
func (r *recorder) Flush() {
|
||||
if f, ok := r.ResponseWriter.(http.Flusher); ok {
|
||||
f.Flush()
|
||||
}
|
||||
}
|
||||
|
||||
// NormalizePath replaces numeric path segments with a placeholder so that
|
||||
// per-route cardinality stays bounded regardless of resource IDs.
|
||||
func NormalizePath(p string) string {
|
||||
|
||||
Reference in New Issue
Block a user