Documentation ¶
Index ¶
- Constants
- func Error(w http.ResponseWriter, err error, ...)
- func GetRemoteAddr(r *http.Request) string
- func Ok(w http.ResponseWriter)
- func OkJson(w http.ResponseWriter, v interface{})
- func Parse(r *http.Request, v interface{}) error
- func ParseForm(r *http.Request, v interface{}) error
- func ParseHeader(headerValue string) map[string]string
- func ParseHeaders(r *http.Request, v interface{}) error
- func ParseJsonBody(r *http.Request, v interface{}) error
- func ParsePath(r *http.Request, v interface{}) error
- func SetErrorHandler(handler func(error) (int, interface{}))
- func WriteJson(w http.ResponseWriter, code int, v interface{})
- type Router
Constants ¶
View Source
const ( // ContentEncoding means Content-Encoding. ContentEncoding = "Content-Encoding" // ContentSecurity means X-Content-Security. ContentSecurity = "X-Content-Security" // ContentType means Content-Type. ContentType = header.ContentType // JsonContentType means application/json. JsonContentType = header.JsonContentType // KeyField means key. KeyField = "key" // SecretField means secret. SecretField = "secret" // TypeField means type. TypeField = "type" // CryptionType means cryption. CryptionType = 1 )
View Source
const ( // CodeSignaturePass means signature verification passed. CodeSignaturePass = iota // CodeSignatureInvalidHeader means invalid header in signature. CodeSignatureInvalidHeader // CodeSignatureWrongTime means wrong timestamp in signature. CodeSignatureWrongTime // CodeSignatureInvalidToken means invalid token in signature. CodeSignatureInvalidToken )
Variables ¶
This section is empty.
Functions ¶
func Error ¶
func Error(w http.ResponseWriter, err error, fns ...func(w http.ResponseWriter, err error))
Error writes err into w.
func GetRemoteAddr ¶
GetRemoteAddr returns the peer address, supports X-Forward-For.
func ParseHeader ¶
ParseHeader parses the request header and returns a map.
func ParseHeaders ¶
ParseHeaders parses the headers request.
func ParseJsonBody ¶
ParseJsonBody parses the post request which contains json in body.
func ParsePath ¶
ParsePath parses the symbols reside in url path. Like http://localhost/bag/:name
func SetErrorHandler ¶
SetErrorHandler sets the error handler, which is called on calling Error.
func WriteJson ¶
func WriteJson(w http.ResponseWriter, code int, v interface{})
WriteJson writes v as json string into w with code.
Types ¶
Click to show internal directories.
Click to hide internal directories.