utils

package
v1.145.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const MaxRequestBodyBytes = 16 << 10

Variables

This section is empty.

Functions

func AuthorizationScheme added in v1.93.0

func AuthorizationScheme(r *http.Request) (scheme, credentials string)

AuthorizationScheme returns the scheme and the trimmed credentials of the Authorization header. RFC 7235 allows more than one space between them.

func CacheDurationOrDefault added in v1.57.0

func CacheDurationOrDefault(d, fallback time.Duration) time.Duration

CacheDurationOrDefault returns d, or fallback if d is non-positive.

func ErrorLogFields added in v1.98.0

func ErrorLogFields(err error) logrus.Fields

ErrorLogFields returns the RFC 6749 fields of err for a log entry. An RFC6749Error's Error() is only its error code, so the hint and debug text reach the log only through these fields.

func GenerateRandomString

func GenerateRandomString(length int) (string, error)

func LimitRequestBody added in v1.60.2

func LimitRequestBody(w http.ResponseWriter, r *http.Request)

func StaticCacheControlValue added in v1.57.0

func StaticCacheControlValue(maxAge time.Duration) string

StaticCacheControlValue returns the Cache-Control value for the JWKS documents, which change rarely and are always revalidated.

func TimeOrZero added in v1.125.0

func TimeOrZero(ts *timestamppb.Timestamp) time.Time

TimeOrZero returns the zero time for a nil Timestamp. AsTime on nil is the 1970 epoch, not "absent".

func ValidateRequestBody

func ValidateRequestBody(w http.ResponseWriter, r *http.Request) bool

func WriteJsonResponse

func WriteJsonResponse(w http.ResponseWriter, status int, data interface{})

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL