link

package
v0.55.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

type Group map[string]*Link

Group returned by Parse, contains multiple links indexed by "rel"

func Parse

func Parse(s string) Group

Parse parses the provided string into a Group

Example
l := Parse(`<https://example.com/?page=2>; rel="next"; title="foo"`)["next"]

fmt.Printf("URI: %q, Rel: %q, Extra: %+v\n", l.URI, l.Rel, l.Extra)
Output:

URI: "https://example.com/?page=2", Rel: "next", Extra: map[title:foo]

func ParseHeader

func ParseHeader(h http.Header) Group

ParseHeader retrieves the Link header from the provided http.Header and parses it into a Group

func ParseRequest

func ParseRequest(req *http.Request) Group

ParseRequest parses the provided *http.Request into a Group

func ParseResponse

func ParseResponse(resp *http.Response) Group

ParseResponse parses the provided *http.Response into a Group

type Link struct {
	URI   string
	Rel   string
	Extra map[string]string
}

Link contains a Link item with URI, Rel, and other non-URI components in Extra.

func (*Link) String

func (l *Link) String() string

String returns the URI

Jump to

Keyboard shortcuts

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