uri

package
v0.18.0-beta11 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUriIsRelative = errors.New("uri is relative")

Functions

This section is empty.

Types

type Uri

type Uri struct {
	// contains filtered or unexported fields
}

Uri define a read-only absolute URI object.

func NewFromFasthttpUri added in v0.18.0

func NewFromFasthttpUri(furi *fasthttp.URI) (Uri, error)

NewFromFasthttpUri returns a new URI from the given URI. This function panics if the given *fasthttp.URI is nil.

func Parse

func Parse(uriStr string) (Uri, error)

Parse parses an absolute URI and normalize it.

func ParseBytes

func ParseBytes(uri []byte) (Uri, error)

ParseBytes parses an URI and normalize it.

func (*Uri) Hash

func (u *Uri) Hash() string

Hash returns hash of URI: bang for https://www.example.com:8080/foo/bar?q=baz#bang

func (*Uri) Host

func (u *Uri) Host() string

Host returns host of URI: www.example.com:8080 for https://www.example.com:8080/foo/bar?q=baz#bang

func (*Uri) HostName added in v0.18.0

func (u *Uri) HostName() string

HostName returns hostname of URI: www.example.com for https://www.example.com:8080/foo/bar?q=baz#bang

func (*Uri) IsValid

func (u *Uri) IsValid() bool

IsValid returns true if data was successfully parsed.

func (Uri) MarshalJSON added in v0.17.0

func (u Uri) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Uri) Origin added in v0.18.0

func (u *Uri) Origin() string

Origin returns origin part of Uri.

func (*Uri) Path

func (u *Uri) Path() string

Path returns normalized path of URI: /foo/bar for https://www.example.com:8080/foo/bar?q=baz#bang

func (*Uri) QueryString

func (u *Uri) QueryString() string

QueryBytes returns extracted query bytes (extractQuery must be true when calling Parse / ParseBytes): q=baz for https://www.example.com:8080/foo/bar?q=baz#bang

func (*Uri) RootUri added in v0.18.0

func (u *Uri) RootUri() Uri

RootUri returns a new Uri with path stripped to / and query args and fragment removed.

func (*Uri) Scan added in v0.17.0

func (u *Uri) Scan(src any) error

Scan implements sql.Scanner.

func (*Uri) Scheme

func (u *Uri) Scheme() string

Scheme returns scheme of URI: https for https://www.example.com:8080/foo/bar?q=baz#bang

func (Uri) String

func (u Uri) String() string

String implements fmt.Stringer.

func (*Uri) UnmarshalJSON added in v0.17.0

func (u *Uri) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*Uri) Value added in v0.17.0

func (u *Uri) Value() (driver.Value, error)

Value implements driver.Valuer.

Jump to

Keyboard shortcuts

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