headers

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultEncoding = "iso-8859-1"

Variables

This section is empty.

Functions

func CharsetOf

func CharsetOf(str string) string

CharsetOf returns a charset parameter value, returning DefaultEncoding in case not presented

func ParamOf

func ParamOf(str, key string) string

ParamOf is an alias to ParamOfOr, except no `or`-parameter is passed - empty string will be returned in case not found.

func ParamOfOr

func ParamOfOr(str, key, or string) string

ParamOfOr looks for a parameter in a value, and if found, returns a parameter value. In case parameter is not found, `or` is returned

func QualityOf

func QualityOf(str string) int

QualityOf simply returns a value of quality-parameter as an uint8. If not presented or is not a valid integer, 9 is returned

func ValueOf

func ValueOf(str string) string

ValueOf returns a value until first semicolon is met. Even if the value after semicolon is not a parameter, it will anyway be counted as a parameter

Types

type Headers

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

Headers is a struct that encapsulates headers map from user, allowing only methods

func NewHeaders

func NewHeaders(underlying map[string][]string) Headers

func (Headers) Add

func (h Headers) Add(key string, newValues ...string)

Add values to the key. In case did not exist, it'll be created

func (Headers) Clear

func (h Headers) Clear()

Clear headers map. Is a system method, that is not supposed to be ever called by user

func (Headers) Has

func (h Headers) Has(key string) bool

Has returns true or false depending on whether such a key exists

func (Headers) Set

func (h Headers) Set(key string, values []string)

Set just sets the value of the header to the provided values slice

func (Headers) Unwrap

func (h Headers) Unwrap() map[string][]string

Unwrap returns an underlying map as it is. This means that modifying it will also affect Headers object

func (Headers) Value

func (h Headers) Value(key string) string

Value does the same as ValueOr does but returning an empty string by default

func (Headers) ValueOr

func (h Headers) ValueOr(key, or string) string

ValueOr returns a header value

func (Headers) Values

func (h Headers) Values(key string) []string

Values returns a slice of values including parameters

Jump to

Keyboard shortcuts

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