Documentation
¶
Overview ¶
Package urlkey derives stable cache-key strings from URLs by applying pragmatic HTTP URL normalization.
The normalization follows RFC 3986 equivalence guidance and HTTP URI rules where applicable (RFC 3986 §6.2, RFC 7230 §2.7.3). It is intended for cache key generation, not as a full URI canonicalization framework.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Normalize ¶
Normalize returns a normalized URL string suitable for use as a cache key.
It normalizes scheme/host case, default ports, dot-segments, and percent-encoding (for path and query), and excludes fragments.
For opaque URLs (u.Opaque != ""), the opaque value is returned unchanged.
Example ¶
package main
import (
"fmt"
"net/url"
"github.com/bartventer/httpcache/pkg/urlkey"
)
func main() {
u, err := url.Parse(
"https://example.com:8443/abc?query=param&another=value#fragment=part1&part2",
)
if err != nil {
panic(err)
}
key := urlkey.Normalize(u)
fmt.Println(key)
}
Output: https://example.com:8443/abc?query=param&another=value
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.