url

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type QueryMap

type QueryMap map[string]interface{}

QueryMap is key value of url query string

type URL

type URL struct {
	Scheme    string
	UserInfo  *UserInfo
	Host      string
	Domain    string
	Subdomain string
	Port      string
	Path      string
	Query     string
	Fragment  string
}

URL is a struct represent segments of a url

func Parse

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

Parse the given url into URL object

func (*URL) AppendPath

func (u *URL) AppendPath(path string) *URL

AppendPath appends given path to current path with no changes to query string

func (*URL) GetBaseDomain

func (u *URL) GetBaseDomain() string

GetBaseDomain return base domain which is Domain prefixed with www as subdomain

func (*URL) GetDomain

func (u *URL) GetDomain() string

GetDomain returns only Domain part of URL without any subdomain or www

func (*URL) GetHost

func (u *URL) GetHost() string

GetHost returns Host part of URL containing subdomain and domain

func (*URL) GetPath

func (u *URL) GetPath() string

GetPath returns only the Path part of url object

func (*URL) GetURLString

func (u *URL) GetURLString() string

GetURLString convert url object into url string [scheme://][userInfo@]host[:port][/path][?query][#fragment]

func (*URL) ReplacePath

func (u *URL) ReplacePath(path string) *URL

ReplacePath replaces given path with current path with no changes to query string

func (*URL) String

func (u *URL) String() string

String is an alias for GetURLString

func (*URL) URI

func (u *URL) URI(path string, params QueryMap) *URL

URI replaces current path and query string with given path and query data

func (*URL) URIAppend

func (u *URL) URIAppend(path string, params QueryMap) *URL

URIAppend Appends given path to current path and replace given query data

type UserInfo

type UserInfo struct {
	Username string
	Password string
}

UserInfo is a struct of url username and password

func NewUserInfo

func NewUserInfo(username string, password string) *UserInfo

NewUserInfo make new instance of UserInfo struct with given data

func (UserInfo) String

func (u UserInfo) String() (str string)

String converts UserInfo object to string

Jump to

Keyboard shortcuts

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