Documentation
¶
Index ¶
- Constants
- Variables
- type AddQueryParamOpt
- type Builder
- func (ub *Builder) AddQueryParam(opt AddQueryParamOpt) error
- func (ub *Builder) DeleteFragment()
- func (ub *Builder) DeleteKeyQuery(keyDelete string)
- func (ub *Builder) GetAllQueryValue() map[string][]string
- func (ub *Builder) GetFullPath() string
- func (ub *Builder) GetInternalURL() url.URL
- func (ub *Builder) GetPaths() []string
- func (ub *Builder) GetURLResult() string
- func (ub *Builder) GetURLResultUnescape() string
- func (ub *Builder) GetValueQuery(key string) string
- func (ub *Builder) SetBaseURL(baseURL string) error
- func (ub *Builder) SetFragment(opt SetFragmentOpt)
- func (ub *Builder) SetPath(path string)
- func (ub *Builder) SetURL(uri string) error
- type Option
- type SetFragmentOpt
Constants ¶
const ( WithoutEncoding = " " // Keep space as is PercentTwentyEncoding = "%20" // Change space into %20 PlusEncoding = "+" // Change space into + )
constants of SpaceEncoding
Variables ¶
var ( // ErrorInvalidSchemeURI error invalid scheme url not in restricted schemes ErrorInvalidSchemeURI = errors.New("invalid scheme url not in restricted schemes") // ErrorKeyEmpty key query parameter cannot be empty ErrorKeyEmpty = errors.New("key query parameter cannot be empty") // ErrorKeyContainSpace key query parameter cannot contains space ErrorKeyContainSpace = errors.New("key query parameter cannot contains space") )
var ( // ErrInvalidURL invalid url ErrInvalidURL = errors.New("invalid scheme url, it should https or http prefix") )
Functions ¶
This section is empty.
Types ¶
type AddQueryParamOpt ¶
type AddQueryParamOpt struct {
// key query
Key string
// value query
Val string
// if you want using DefaultSpaceEncoding as SpaceEnc
UseDefaultEncode bool
// specify space encode if you use custom encoding
SpaceEnc string
}
AddQueryParamOpt parameter for adding query params value in url
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder base struct uruki
func NewBuilder ¶
NewBuilder create uruki (URi qUicK buIlder) parser & wrapper of net/url
func (*Builder) AddQueryParam ¶
func (ub *Builder) AddQueryParam(opt AddQueryParamOpt) error
AddQueryParam add query parameter values, internally will be encode the value of query
func (*Builder) DeleteFragment ¶
func (ub *Builder) DeleteFragment()
DeleteFragment remove existing fragment if any
func (*Builder) DeleteKeyQuery ¶
DeleteKeyQuery delete key query parameter if exist
func (*Builder) GetAllQueryValue ¶
GetAllQueryValue get all key-value of existing query parameter, return as map key and decoded value
func (*Builder) GetFullPath ¶
GetFullPath get full path. exclude base url, query parameter and fragment
func (*Builder) GetInternalURL ¶
GetInternalURL get internal url that already parsed by uruki
func (*Builder) GetURLResult ¶
GetURLResult get url result with escaped option
func (*Builder) GetURLResultUnescape ¶
GetURLResultUnescape get result url with unescape string
func (*Builder) GetValueQuery ¶
GetValueQuery get value of existing query parameter if any, return as decoded value
func (*Builder) SetBaseURL ¶
SetBaseURL change or update existing of base url only host and port
func (*Builder) SetFragment ¶
func (ub *Builder) SetFragment(opt SetFragmentOpt)
SetFragment create / update existing fragment for references, without '#'
type Option ¶
type Option struct {
// URL: url to proceed
URL string
// RestrictScheme: if you want your url scheme keep as is, example []string{"https"} if any url set with "http" options this will be return error
RestrictScheme []string
// DefaultSpaceEncode: default space encoding for internally encode. see SpaceEncoding const for more the details
DefaultSpaceEncode string
// UseEscapeAutomateURL to automate query escape on existing url query parameter while initiating builder / SetURL(uri string)
UseEscapeAutomateURL bool
}
Option options to create new Builder
type SetFragmentOpt ¶
type SetFragmentOpt struct {
// fragment value
Fragment string
// if you want using DefaultSpaceEncoding as SpaceEnc
UseDefaultEncode bool
// specify space encode if you use custom encoding
SpaceEnc string
}
SetFragmentOpt parameter for adding query params value in url