VictoriaMetrics/lib/httputils/bool.go

18 lines
320 B
Go
Raw Normal View History

package httputils
import (
"net/http"
"strings"
)
// GetBool returns boolean value from the given argKey query arg.
func GetBool(r *http.Request, argKey string) bool {
argValue := r.FormValue(argKey)
switch strings.ToLower(argValue) {
case "", "0", "f", "false", "no":
return false
default:
return true
}
}