Documentation ¶
Index ¶
- Variables
- func AuthUnescape(into *[]byte, b []byte) error
- func FragmentUnescape(into *[]byte, b []byte) error
- func HasAsciiControlBytes(b []byte) bool
- func HostUnescape(into *[]byte, b []byte) error
- func IsValidPercentEncoding(b []byte) (bool, error)
- func PathEscape(into *[]byte, b []byte)
- func PathUnescape(into *[]byte, b []byte) error
- func QueryEscape(into *[]byte, b []byte)
- func QueryUnescape(into *[]byte, b []byte) error
- func ReleaseQueryParams(params *QueryParams)
- func ReleaseURI(uri *URI)
- func ZoneUnescape(into *[]byte, b []byte) error
- type Bytes
- type QueryParams
- func (q *QueryParams) Add(key []byte, value []byte, join byte)
- func (q *QueryParams) AddString(key string, value string, join byte)
- func (q *QueryParams) CopyTo(dst *QueryParams)
- func (q *QueryParams) Delete(key []byte)
- func (q *QueryParams) DeleteString(key string)
- func (q *QueryParams) Get(key []byte) (Bytes, bool)
- func (q *QueryParams) GetString(key string) (Bytes, bool)
- func (q *QueryParams) Len() int
- func (q *QueryParams) Params() bytes.Bytes
- func (q *QueryParams) Parse(b []byte) error
- func (q *QueryParams) ParseString(s string) error
- func (q *QueryParams) Reset()
- func (q *QueryParams) Set(key []byte, value []byte)
- func (q *QueryParams) SetString(key string, value string)
- func (q *QueryParams) Sort()
- type URI
- func (u *URI) CopyTo(dst *URI)
- func (u *URI) Fragment() bytes.Bytes
- func (u *URI) FullURI() bytes.Bytes
- func (u *URI) Host() bytes.Bytes
- func (u *URI) Opaque() bytes.Bytes
- func (u *URI) Parse(uri []byte) error
- func (u *URI) ParseRequest(uri []byte) error
- func (u *URI) ParseRequestString(uri string) error
- func (u *URI) ParseString(uri string) error
- func (u *URI) Password() bytes.Bytes
- func (u *URI) Path() bytes.Bytes
- func (u *URI) Query() *QueryParams
- func (u *URI) RawPath() bytes.Bytes
- func (u *URI) RawQuery() bytes.Bytes
- func (u *URI) RequestURI() bytes.Bytes
- func (u *URI) Reset()
- func (u *URI) Scheme() bytes.Bytes
- func (u *URI) SetFragment(b []byte)
- func (u *URI) SetFragmentString(s string)
- func (u *URI) SetHost(b []byte)
- func (u *URI) SetHostString(s string)
- func (u *URI) SetOpaque(b []byte)
- func (u *URI) SetOpaqueString(s string)
- func (u *URI) SetPassword(b []byte)
- func (u *URI) SetPasswordString(s string)
- func (u *URI) SetPath(b []byte)
- func (u *URI) SetPathString(s string)
- func (u *URI) SetQuery(b []byte)
- func (u *URI) SetQueryString(s string)
- func (u *URI) SetScheme(b []byte)
- func (u *URI) SetSchemeString(s string)
- func (u *URI) SetUsername(b []byte)
- func (u *URI) SetUsernameString(s string)
- func (u *URI) ToURL() url.URL
- func (u *URI) Username() bytes.Bytes
Constants ¶
This section is empty.
Variables ¶
var ( ErrBadPercentEncode = errors.New("uri: bad percent encoding") ErrShouldBeEscaped = errors.New("uri: byte should be escaped") )
Percent encode parsing errors
var ( ErrContainsCtrlByte = errors.New("uri: contains ascii ctrl byte") ErrInvalidScheme = errors.New("uri: invalid scheme") ErrInvalidIPLiteral = errors.New("uri: invalid ip literal") ErrInvalidPort = errors.New("uri: invalid port after host") )
URI parsing errors
Functions ¶
func AuthUnescape ¶
func FragmentUnescape ¶
func HasAsciiControlBytes ¶
HasAsciiControlBytes returns whether a byte slice contains ASCII control bytes
func HostUnescape ¶
func IsValidPercentEncoding ¶
IsValidPercentEncoding returns error on bad percent encoding within the supplied byte slice. Bool returned is whether you need to escape the slice. This only checks for valid path percent-encoding
func PathEscape ¶
func PathUnescape ¶
func QueryEscape ¶
func QueryUnescape ¶
func ReleaseQueryParams ¶
func ReleaseQueryParams(params *QueryParams)
ReleaseQueryParams resets and releases a QueryParams object back to the pool
func ReleaseURI ¶
func ReleaseURI(uri *URI)
ReleaseURI resets and releases a URI object back to the pool
func ZoneUnescape ¶
Types ¶
type Bytes ¶
type Bytes []byte
Bytes is the simplest possible implementation of bytes.Bytes, with convenient length and capacity methods
type QueryParams ¶
type QueryParams struct {
// contains filtered or unexported fields
}
QueryParams represents parsed query parameters
func AcquireQueryParams ¶
func AcquireQueryParams() *QueryParams
AcquireQueryParams acquires a QueryParams object from the global pool
func NewParams ¶
func NewParams() QueryParams
NewParams returns a new initialized QueryParams object
func (*QueryParams) Add ¶
func (q *QueryParams) Add(key []byte, value []byte, join byte)
Add adds the supplied value to the parameter at supplied key, using the supplied 'join' as a separator byte. A new parameter will be created if necessary
func (*QueryParams) AddString ¶
func (q *QueryParams) AddString(key string, value string, join byte)
AddString adds the supplied value to the parameter at supplied key, using the supplied 'join' as a separator byte. A new parameter will be created if necessary
func (*QueryParams) CopyTo ¶
func (q *QueryParams) CopyTo(dst *QueryParams)
CopyTo copies the current state of QueryParams into the other object
func (*QueryParams) Delete ¶
func (q *QueryParams) Delete(key []byte)
Delete deletes the paramater with key from the QueryParams object
func (*QueryParams) DeleteString ¶
func (q *QueryParams) DeleteString(key string)
DeleteString deletes the paramater with key from the QueryParams object
func (*QueryParams) Get ¶
func (q *QueryParams) Get(key []byte) (Bytes, bool)
Get attempts to return the param value for supplied key
func (*QueryParams) GetString ¶
func (q *QueryParams) GetString(key string) (Bytes, bool)
GetString attempts to return the param value for supplied key
func (*QueryParams) Len ¶
func (q *QueryParams) Len() int
Len returns the number of query key-value pairs
func (*QueryParams) Params ¶
func (q *QueryParams) Params() bytes.Bytes
Params returns the the current state of the QueryParams object as bytes.Bytes
func (*QueryParams) Parse ¶
func (q *QueryParams) Parse(b []byte) error
Parse parses the supplied query bytes into the QueryParams object, returning error on invalid percent encoding
func (*QueryParams) ParseString ¶
func (q *QueryParams) ParseString(s string) error
ParseString parses the supplied query bytes into the QueryParams object, returning error on invalid percent encoding
func (*QueryParams) Set ¶
func (q *QueryParams) Set(key []byte, value []byte)
Set sets the parameter with key, to the supplied value. A new parameter will be created if necessary
func (*QueryParams) SetString ¶
func (q *QueryParams) SetString(key string, value string)
SetString sets the parameter with key, to the supplied value. A new parameter will be created if necessary
func (*QueryParams) Sort ¶
func (q *QueryParams) Sort()
Sort sorts the query parameters alphabetically by key
type URI ¶
type URI struct {
// contains filtered or unexported fields
}
URI represents a parsed URI structure
func (*URI) Fragment ¶
func (u *URI) Fragment() bytes.Bytes
Fragment returns the fragment byte buffer
func (*URI) FullURI ¶
func (u *URI) FullURI() bytes.Bytes
FullURI returns the full URI of form: {Scheme}://{Host}/{Path}?{Query}#{Fragment} or {Scheme}:{Opaque}?{Query}#{Fragment}
func (*URI) ParseRequest ¶
func (*URI) ParseRequestString ¶
func (*URI) ParseString ¶
ParseString attempts to parse supplied URI string into the receiving object
func (*URI) Password ¶
func (u *URI) Password() bytes.Bytes
Password returns the password byte buffer
func (*URI) Query ¶
func (u *URI) Query() *QueryParams
Query returns the query parameters, parsing raw query if necessary
func (*URI) RawPath ¶
func (u *URI) RawPath() bytes.Bytes
RawPath returns the raw path (i.e. not normalized) byte buffer
func (*URI) RawQuery ¶
func (u *URI) RawQuery() bytes.Bytes
RawQuery returns the raw query byte buffer
func (*URI) RequestURI ¶
func (u *URI) RequestURI() bytes.Bytes
RequestURI returns the request URI of form: /{Path}?{Query}
func (*URI) SetFragment ¶
SetFragment sets the fragment byte buffer to the supplied bytes
func (*URI) SetFragmentString ¶
SetFragmentString sets the fragment byte buffer to the supplied string
func (*URI) SetHost ¶
SetHost sets the host byte buffer to the supplied bytes, formatted to lowercase
func (*URI) SetHostString ¶
SetHostString sets the host byte buffer to the supplied string, formatted to lowercase
func (*URI) SetOpaqueString ¶
SetOpaqueString sets the host byte buffer to the supplied string
func (*URI) SetPassword ¶
SetPassword sets the password byte buffer to the supplied bytes
func (*URI) SetPasswordString ¶
SetPasswordStrings sets the password byte buffer to the suppied string
func (*URI) SetPath ¶
SetPath sets the raw path byte buffer to supplied bytes, and sets the normalized path buffer to the normalized form of this
func (*URI) SetPathString ¶
SetPathString sets the raw path byte buffer to supplied string, and sets the normalized path buffer to the normalized form of this
func (*URI) SetQueryString ¶
SetQueryString sets the query byte buffer to the supplied string
func (*URI) SetScheme ¶
Scheme sets the scheme byte buffer to the supplied bytes, formatted to lowercase
func (*URI) SetSchemeString ¶
SetSchemeString sets the scheme byte buffer to the supplied string, formatted to lowercase
func (*URI) SetUsername ¶
SetUsername sets the username byte buffer to the supplied bytes
func (*URI) SetUsernameString ¶
SetUsernameString sets the username byte buffer to the supplied string