Documentation ¶
Index ¶
- Variables
- type URL
- func (u *URL) AccountID() []byte
- func (u *URL) AccountID32() [32]byte
- func (u *URL) Compare(v *URL) int
- func (u *URL) Copy() *URL
- func (u *URL) Equal(v *URL) bool
- func (u *URL) Hash() []byte
- func (u *URL) Hostname() string
- func (u *URL) Identity() *URL
- func (u *URL) IdentityAccountID() []byte
- func (u *URL) IdentityAccountID32() [32]byte
- func (u *URL) JoinPath(s ...string) *URL
- func (u *URL) LocalTo(v *URL) bool
- func (u *URL) MarshalJSON() ([]byte, error)
- func (u *URL) Parent() (*URL, bool)
- func (u *URL) ParentOf(v *URL) bool
- func (u *URL) Password() string
- func (u *URL) Port() string
- func (u *URL) QueryValues() Values
- func (u *URL) RawString() string
- func (u *URL) RootIdentity() *URL
- func (u *URL) Routing() uint64
- func (u *URL) ShortString() string
- func (u *URL) String() string
- func (u *URL) URL() *url.URL
- func (u *URL) UnmarshalJSON(data []byte) error
- func (u *URL) Username() string
- type Values
Constants ¶
This section is empty.
Variables ¶
var ErrMissingHost = errors.New("missing host")
ErrMissingHost means that a URL did not include a hostname.
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 ¶
URL is an Accumulate URL.
func Parse ¶
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 ¶
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 ¶
AccountID32 returns AccountID as a [32]byte.
func (*URL) Compare ¶ added in v0.5.1
Compare returns an integer comparing two URLs as lower case strings. The result will be 0 if u == v, -1 if u < v, and +1 if u > v.
func (*URL) Equal ¶
Equal reports whether u and v, converted to strings and interpreted as UTF-8, are equal under Unicode case-folding.
func (*URL) Hash ¶ added in v0.5.1
Hash calculates a hash of the URL starting with AccountID, hashing and concatenating Query unless it is empty, and hashing and concatenating Fragment unless it is empty. If Query and Fragment are both non-empty, with H defined as the SHA-256 hash of the lower case of the operand, the result is H(H(AccountID + H(Query)) + H(Fragment)).
func (*URL) IdentityAccountID ¶
IdentityAccountID constructs an account identifier from the lower case hostname. The port is not included.
ID = Hash(LowerCase(u.Host()))
func (*URL) IdentityAccountID32 ¶
IdentityAccountID32 returns IdentityAccountID as a [32]byte.
func (*URL) LocalTo ¶ added in v0.6.0
LocalTo returns true if U is local to V, that is if they have the same root identity.
func (*URL) MarshalJSON ¶
MarshalJSON marshals the URL to JSON as a string.
func (*URL) Parent ¶ added in v0.5.1
Parent gets the URL's parent path, or returns the original URL and false.
func (*URL) QueryValues ¶
QueryValues parses Query and returns the corresponding values. It silently discards malformed value pairs. To check errors use net/url.ParseQuery.
func (*URL) RawString ¶
RawString concatenates all of the URL parts. Does not percent-encode anything. Primarily used for validation.
func (*URL) RootIdentity ¶ added in v0.5.1
RootIdentity returns a copy of the URL with an empty path.
func (*URL) Routing ¶
Routing returns the first 8 bytes of the identity account ID as an integer.
Routing = uint64(u.IdentityAccountID()[:8])
func (*URL) ShortString ¶ added in v0.6.0
ShortString returns String without the scheme prefix.
func (*URL) UnmarshalJSON ¶
UnmarshalJSON unmarshals the URL from JSON as a string.