mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
tsweb: support recording unabridged HTTP status codes as well.
Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
parent
561f7be434
commit
c48513b2be
@ -21,6 +21,7 @@
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -88,7 +89,6 @@ func AllowDebugAccess(r *http.Request) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// AcceptsEncoding reports whether r accepts the named encoding
|
// AcceptsEncoding reports whether r accepts the named encoding
|
||||||
// ("gzip", "br", etc).
|
// ("gzip", "br", etc).
|
||||||
func AcceptsEncoding(r *http.Request, enc string) bool {
|
func AcceptsEncoding(r *http.Request, enc string) bool {
|
||||||
@ -192,6 +192,10 @@ type HandlerOptions struct {
|
|||||||
// of status codes for handled responses.
|
// of status codes for handled responses.
|
||||||
// The keys are "1xx", "2xx", "3xx", "4xx", and "5xx".
|
// The keys are "1xx", "2xx", "3xx", "4xx", and "5xx".
|
||||||
StatusCodeCounters *expvar.Map
|
StatusCodeCounters *expvar.Map
|
||||||
|
// If non-nil, StatusCodeCountersFull maintains counters of status
|
||||||
|
// codes for handled responses.
|
||||||
|
// The keys are HTTP numeric response codes e.g. 200, 404, ...
|
||||||
|
StatusCodeCountersFull *expvar.Map
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReturnHandlerFunc is an adapter to allow the use of ordinary
|
// ReturnHandlerFunc is an adapter to allow the use of ordinary
|
||||||
@ -301,6 +305,10 @@ func (h retHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
key := fmt.Sprintf("%dxx", msg.Code/100)
|
key := fmt.Sprintf("%dxx", msg.Code/100)
|
||||||
h.opts.StatusCodeCounters.Add(key, 1)
|
h.opts.StatusCodeCounters.Add(key, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if h.opts.StatusCodeCountersFull != nil {
|
||||||
|
h.opts.StatusCodeCountersFull.Add(strconv.Itoa(msg.Code), 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// loggingResponseWriter wraps a ResponseWriter and record the HTTP
|
// loggingResponseWriter wraps a ResponseWriter and record the HTTP
|
||||||
|
Loading…
Reference in New Issue
Block a user