Documentation ¶
Overview ¶
Package rfc8288 contains an implementation of IETF's RFC 8288. See: https://tools.ietf.org/html/rfc8288
Index ¶
- Constants
- Variables
- func LinkHeader(links ...Link) string
- func LinkHeaderValue(links ...Link) string
- type Link
- func (l *Link) Extend(key string, value interface{}) error
- func (l *Link) Extension(key string) (interface{}, bool)
- func (l Link) ExtensionKeys() []string
- func (l Link) MarshalJSON() ([]byte, error)
- func (l Link) String() string
- func (l *Link) StringExtension(key string) (string, bool)
- func (l *Link) UnmarshalJSON(data []byte) error
Constants ¶
const ( INVALID token = iota // delimiters QUOTE SEMICOLON LT GT EQ // special EOF STAR // multi-character WORD WS // reserved attribute names REL REV ANCHOR HREFLANG MEDIA TITLE TYPE )
token types
Variables ¶
var ( // ErrExtensionKeyIsReserved describes an attempt to call Link.Extend(k,v) with a reserved key name ErrExtensionKeyIsReserved = errors.New("rfc8288: the given extension key name is reserved please choose another name") // ReservedKeys holds the names of all the reserved key names that are not allowed to be used as extensions ReservedKeys = map[string]struct{}{ "href": {}, "rel": {}, "rev": {}, "anchor": {}, "hreflang": {}, "media": {}, "title": {}, "title*": {}, "type": {}, } )
var ( ErrInvalidLink = errors.New("rfc8288: invalid link") ErrMissingSemicolon = errors.New("rfc8288: invalid link, missing semicolon") ErrMissingClosingQuote = errors.New("rfc8288: invalid link, missing closing quote") ErrMissingAttrValue = errors.New("rfc8288: invalid link, missing attribute value") )
parse Error Types
Functions ¶
func LinkHeader ¶
func LinkHeaderValue ¶
Types ¶
type Link ¶
type Link struct { HREF url.URL Rel string Rev string Anchor string HREFLang string Media string Title string TitleStar string Type string // contains filtered or unexported fields }
Link is an implementation of the structure defined by RFC8288 Web Linking
func ParseLinkHeaders ¶
func (*Link) Extend ¶
Extend adds an extension to the Link. Only non-reserved extension keys are allowed. Setting the value to nil will remove the extension.
func (*Link) Extension ¶
Extension retrieves the value for an extension if present. A bool is also returned to signify whether the value was present upon retrieval
func (Link) ExtensionKeys ¶
ExtensionKeys returns a slice of strings representing the names of extension keys for this Link struct in the order they were added
func (Link) String ¶
String returns the Link in a format usable for HTTP Headers as defined by RFC8288
func (*Link) UnmarshalJSON ¶
UnmarshalJSON unmarshal JSON