fix various endpoints

This commit is contained in:
yusing
2025-02-13 15:05:16 +08:00
parent 02d1c9ce98
commit decd2c2ded
9 changed files with 39 additions and 51 deletions

View File

@@ -25,17 +25,17 @@ import (
// If the request is a websocket request, it serves the data for the given period for every interval.
func (p *Poller[T, AggregateT]) ServeHTTP(w http.ResponseWriter, r *http.Request) {
query := r.URL.Query()
interval := metricsutils.QueryDuration(query, "interval", 0)
minInterval := 1 * time.Second
if interval == 0 {
interval = p.interval()
}
if interval < minInterval {
interval = minInterval
}
if httpheaders.IsWebsocket(r.Header) {
interval := metricsutils.QueryDuration(query, "interval", 0)
minInterval := 1 * time.Second
if interval == 0 {
interval = p.interval()
}
if interval < minInterval {
interval = minInterval
}
utils.PeriodicWS(w, r, interval, func(conn *websocket.Conn) error {
data, err := p.getRespData(r)
if err != nil {