Documentation ¶
Overview ¶
Package httplink defines a representation of Web Linkings.
Index ¶
Constants ¶
const ( ParamRel = "rel" ParamAs = "as" ParamCrossOrigin = "crossorigin" ParamMedia = "media" ParamType = "type" )
A few common parameter names for use with LinkParams.
const ( // Value(s) for the "rel" parameter. RelPreload = "preload" // Value(s) for the "crossorigin" parameter. CrossOriginAnonymous = "anonymous" )
Special parameter values recognized by LinkParams.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Link ¶
type Link struct { URL *url.URL Params LinkParams }
Link represents a Web Linking [RFC 8288], aka. the Link HTTP header.
func NewLink ¶
NewLink creates and initializes a new Link with the provided URL u and the provided rel parameter.
func Parse ¶
Parse parses the Link HTTP header value. It returns a slice since the value may contain multiple links, separated by comma.
func (*Link) Equal ¶
Equal reports whether l and m have the same URL and parameters. The URLs are compared by strings.
type LinkParams ¶
LinkParams represents the parameters of a Web Linking.
func (LinkParams) Clone ¶
func (p LinkParams) Clone() LinkParams
Clone returns a deep copy of the LinkParams p.
func (LinkParams) Equal ¶
func (p LinkParams) Equal(q LinkParams) bool
Equal reports whether p and q contain the same set of key-value pairs.
func (LinkParams) Get ¶
func (p LinkParams) Get(key string) string
Get returns the value of the parameter specified by key. key gets lowered, thus is case-insensitive.
func (LinkParams) Set ¶
func (p LinkParams) Set(key, val string)
Set changes the value of the parameter specified by key. key gets lowered, thus is case-insensitive. Set also normalizes the provided value for some parameters, e.g. removes extra spaces for the rel parameter. To get around the normalization, access the map entry directly.