utils

package
v1.14.6 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BuildDate   = ""
	BuildName   = "dev"
	VersionName = "0"
)
View Source
var ErrPathAboveRoot = errors.New("path resolves above the root")

ErrPathAboveRoot reports a path whose dot segments resolve above the root.

Functions

func CollectMetricNames

func CollectMetricNames(header string, timings ServerTimings)

CollectMetricNames collects metric names from the given Server-Timing HTTP header field. See https://www.w3.org/TR/server-timing/

func HasEmptyOrDotSegment added in v1.14.6

func HasEmptyOrDotSegment(path string) bool

HasEmptyOrDotSegment reports whether a decoded path contains an empty or dot segment. A trailing slash is not an empty segment.

func JoinOpenAPIPath

func JoinOpenAPIPath(elements ...string) string

func JoinPath

func JoinPath(elements ...string) string

JoinPath ensures the file-muxer behaviour for redirecting '/path' to '/path/' if not explicitly specified.

func MergeMetrics

func MergeMetrics(src, dest ServerTimings)

MergeMetrics merges timings from 'src' into 'dest'.

func NormalizePath added in v1.14.6

func NormalizePath(escaped string) (string, error)

NormalizePath removes dot segments and merges slashes of an escaped path (RFC 3986 section 5.2.4). Only a segment made of literal or %2E-encoded dots is decoded, every other byte is kept, so an encoded slash stays inside its segment. A ".." above the root is an error, not clamped.

func NormalizeURLPath added in v1.14.6

func NormalizeURLPath(u *url.URL) error

NormalizeURLPath rewrites Path and RawPath of u to the normalized form of its path, so that EscapedPath keeps the encoding of the normalized form. It starts from RawPath, the path as sent. EscapedPath would re-encode Path when RawPath holds a byte like "|" that Go escapes, and that turns %2F into a slash.

Types

type ServerTimings

type ServerTimings map[string]string

Jump to

Keyboard shortcuts

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