uri

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

Package uri provides a helper for URI validation and parsing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsHostnameOnly

func IsHostnameOnly(host string) error

Types

type Defaults

type Defaults struct {
	Port   string
	Scheme string
}

type URI

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

func New

func New(rawUri string, defaults *Defaults) (res *URI, err error)

New parses a given rawUri and returns a new filled URI structure. It ignores embedded credentials according to https://www.ietf.org/rfc/rfc3986.txt. Use NewWithCreds to add credentials to a structure.

func NewWithCreds

func NewWithCreds(rawUri, user, password string, defaults *Defaults) (res *URI, err error)

func (*URI) Addr

func (u *URI) Addr() string

Addr combines a host and a port into a network address ("host:port") or returns a socket.

func (*URI) GetParam

func (u *URI) GetParam(key string) string

func (*URI) Host

func (u *URI) Host() string

func (*URI) NoQueryString added in v0.0.2

func (u *URI) NoQueryString() string

NoQueryString reassembles the URI to a valid URI string with no query.

func (*URI) Password

func (u *URI) Password() string

func (*URI) Path

func (u *URI) Path() string

func (*URI) Port

func (u *URI) Port() string

func (*URI) Query

func (u *URI) Query() string

func (*URI) Scheme

func (u *URI) Scheme() string

func (*URI) Socket

func (u *URI) Socket() string

func (*URI) String

func (u *URI) String() string

String reassembles the URI to a valid URI string.

func (*URI) User

func (u *URI) User() string

type URIValidator

type URIValidator struct {
	Defaults       *Defaults
	AllowedSchemes []string
}

func (URIValidator) Validate

func (v URIValidator) Validate(value *string) error

Jump to

Keyboard shortcuts

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