url

package
v0.5.1-rc1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingHost = errors.New("missing host")

ErrMissingHost means that a URL did not include a hostname.

View Source
var ErrWrongScheme = errors.New("wrong scheme")

ErrWrongScheme means that a URL included a scheme other than the Accumulate scheme.

Functions

This section is empty.

Types

type URL

type URL struct {
	UserInfo  string
	Authority string
	Path      string
	Query     string
	Fragment  string
}

URL is an Accumulate URL.

func MustParse added in v0.5.1

func MustParse(s string) *URL

MustParse calls Parse and panics if it returns an error.

func Parse

func Parse(s string) (*URL, error)

Parse parses the string as an Accumulate URL. The scheme may be omitted, in which case `acc://` will be added, but if present it must be `acc`. The hostname must be non-empty. RawPath, ForceQuery, and RawFragment are not preserved.

func (*URL) AccountID

func (u *URL) AccountID() []byte

AccountID constructs an account identifier from the lower case hostname and path. The port is not included. If the path does not begin with `/`, `/` is added between the hostname and the path.

ID = Hash(LowerCase(Sprintf("%s/%s", u.Host(), u.Path)))

func (*URL) AccountID32

func (u *URL) AccountID32() [32]byte

AccountID32 returns AccountID as a [32]byte.

func (*URL) Equal

func (u *URL) Equal(v *URL) bool

Equal reports whether u and v, converted to strings and interpreted as UTF-8, are equal under Unicode case-folding.

func (*URL) Hostname

func (u *URL) Hostname() string

Hostname returns the hostname from the authority component.

func (*URL) Identity

func (u *URL) Identity() *URL

Identity returns a copy of the URL with an empty path.

func (*URL) IdentityAccountID

func (u *URL) IdentityAccountID() []byte

IdentityAccountID constructs an account identifier from the lower case hostname. The port is not included.

ID = Hash(LowerCase(u.Host()))

func (*URL) IdentityAccountID32

func (u *URL) IdentityAccountID32() [32]byte

IdentityAccountID32 returns IdentityAccountID as a [32]byte.

func (*URL) JoinPath

func (u *URL) JoinPath(s ...string) *URL

JoinPath returns a copy of U with additional path elements.

func (*URL) MarshalJSON

func (u *URL) MarshalJSON() ([]byte, error)

MarshalJSON marshals the URL to JSON as a string.

func (*URL) Password

func (u *URL) Password() string

Password returns the password from the user info component.

func (*URL) Port

func (u *URL) Port() string

Port returns the port from the authority component.

func (*URL) QueryValues

func (u *URL) QueryValues() Values

QueryValues parses Query and returns the corresponding values. It silently discards malformed value pairs. To check errors use net/url.ParseQuery.

func (*URL) RawString

func (u *URL) RawString() string

RawString concatenates all of the URL parts. Does not percent-encode anything. Primarily used for validation.

func (*URL) Routing

func (u *URL) Routing() uint64

Routing returns the first 8 bytes of the identity account ID as an integer.

Routing = uint64(u.IdentityAccountID()[:8])

func (*URL) String

func (u *URL) String() string

String reassembles the URL into a valid URL string. See net/url.URL.String().

func (*URL) URL

func (u *URL) URL() *url.URL

URL returns a net/url.URL.

func (*URL) UnmarshalJSON

func (u *URL) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the URL from JSON as a string.

func (*URL) Username

func (u *URL) Username() string

Username returns the username from the user info component.

type Values

type Values = url.Values

Jump to

Keyboard shortcuts

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