Documentation
¶
Index ¶
- Variables
- func AddHeader(w http.ResponseWriter, k string, v interface{})
- func AddPrefixSlash(p string) string
- func AppendToVaryHeader(vary string, fields []string) string
- func BytesToString(b []byte) string
- func Dirname() (string, error)
- func EncodeURI(str string) string
- func EncodeURIComponent(str string) string
- func FileExists(absPath string) bool
- func FormatMediaType(m MediaType) (string, error)
- func Fresh(reqHeader, resHeader http.Header) bool
- func GetHeaderValues(h http.Header, key string) []string
- func H(k string) string
- func HasBody(req *http.Request) bool
- func IsFileExist(path string) bool
- func LookupCharset(mimeType string) string
- func LookupMimeType(s string) string
- func Max(x, y int) int
- func Min(x, y int) int
- func ParseHeader(header string) []string
- func RequestTypeIs(req *http.Request, types ...string) string
- func RouteJoin(routes ...string) string
- func SetContentType(w http.ResponseWriter, s string)
- func SetHeader(w http.ResponseWriter, value ...interface{})
- func StringToBytes(s string) (b []byte)
- func TestMediaType(s string) bool
- func TypeIs(contentType string, types ...string) string
- func Vary(w http.ResponseWriter, fields []string)
- type AcceptParams
- type MediaType
- type Range
- type Ranges
- type StringSlice
Constants ¶
This section is empty.
Variables ¶
var (
InitDirnameErr error
)
Functions ¶
func AddHeader ¶
func AddHeader(w http.ResponseWriter, k string, v interface{})
AddHeader adds the specified value to the HTTP response header field. If the header is not already set, it creates the header with the specified value. The value parameter can be a string or a string slice.
func AddPrefixSlash ¶
AddPrefixSlash adds a slash to the start of given string
func AppendToVaryHeader ¶
AppendToVaryHeader appends fields to the vary field of header.
func BytesToString ¶
BytesToString converts byte slice to string without a memory allocation.
func Dirname ¶
Dirname returns the directory name of executable file that started the current process.
func EncodeURIComponent ¶
EncodeURIComponent encodes a text string as a valid component of a Uniform Resource Identifier (URI).
func FileExists ¶
FileExists returns true if specified absolute file path exists.
func FormatMediaType ¶
Format object to media type
func GetHeaderValues ¶
GetHeaderValues returns the header values of specified key. This is a patch function of http.Header.Values for go version lower than 1.4
func HasBody ¶
HasBody checks if a request has a request body. A request with a body __must__ either have `transfer-encoding` or `content-length` headers set.
http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.3
func LookupCharset ¶
LookupCharset lookups the charset of MIME Type.
func LookupMimeType ¶
LookupMimeType lookups the MIME Type of a suffix string.
func ParseHeader ¶
ParseHeader parses header with type string into a slice.
func SetContentType ¶
func SetContentType(w http.ResponseWriter, s string)
SetContentType sets the Content-Type HTTP header to the MIME type as determined by LookupMimeType() for the specified type. If type contains the “/” character, then it sets the Content-Type to type.
func SetHeader ¶
func SetHeader(w http.ResponseWriter, value ...interface{})
SetHeader sets the response’s HTTP header field to value. To set multiple fields at once, pass a string map as the parameter.
func StringToBytes ¶
StringToBytes converts string to byte slice without a memory allocation.
func Vary ¶
func Vary(w http.ResponseWriter, fields []string)
Vary marks that a request is varied on a header field.
Types ¶
type AcceptParams ¶
AcceptParams is an object with `.value`, `.quality` and `.params`.
func NormalizeType ¶
func NormalizeType(t string) AcceptParams
NormalizeType normalizes the given `type`, for example "html" becomes "text/html".
type StringSlice ¶
type StringSlice []string
StringSlice attaches the methods of Interface to []string.
func (StringSlice) Contains ¶
func (s StringSlice) Contains(str string) bool
Contains reports whether str is within the string slice.
func (StringSlice) Filter ¶
func (s StringSlice) Filter(f func(string) bool) []string
Filter returns a new string slice with matched values.
func (StringSlice) Index ¶
func (s StringSlice) Index(str string) int
Index returns the index of str in the string slice.