Documentation
¶
Index ¶
- Constants
- Variables
- func Error(w http.ResponseWriter, err error, ...)
- func GetFormValues(r *http.Request) (map[string]interface{}, 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 Response(w http.ResponseWriter, resp interface{}, err error)
- func ResponseWithLang(r *http.Request, w http.ResponseWriter, l *lang.Lang, resp interface{}, ...)
- func ResponseWithLangAndData(r *http.Request, w http.ResponseWriter, l *lang.Lang, resp interface{}, ...)
- func SetErrorHandler(handler func(error) (int, interface{}))
- func WriteJson(w http.ResponseWriter, code int, v interface{})
- type Body
- type RequestSvc
- type Router
- type User
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 ¶
View Source
var ErrUserInvalid = errors.New("user invalid")
Functions ¶
func Error ¶
func Error(w http.ResponseWriter, err error, fns ...func(w http.ResponseWriter, err error))
Error writes err into w.
func GetFormValues ¶
GetFormValues returns the form values.
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 Response ¶
func Response(w http.ResponseWriter, resp interface{}, err error)
func ResponseWithLang ¶
func ResponseWithLangAndData ¶
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 ¶
type RequestSvc ¶
func NewRequestWithTokenValue ¶
func NewRequestWithTokenValue(r *http.Request, tokenValue string) (RequestSvc, error)
type Router ¶
type Router interface {
http.Handler
Handle(method, path string, handler http.Handler) error
SetNotFoundHandler(handler http.Handler)
SetNotAllowedHandler(handler http.Handler)
}
Router interface represents a http router that handles http requests.
type User ¶
type User struct {
Id int `json:"id"`
Role int `json:"role"`
Username string `json:"username"`
Email string `json:"email"`
Portrait string `json:"portrait"`
Language string `json:"language"`
Timezone string `json:"timezone"`
WebTitle string `json:"webTitle"`
ClientType string `json:"clientType"`
Item string `json:"item"`
Version string `json:"version"`
CreatedAt int `json:"createdAt"`
IsEmailConfirm int `json:"isEmailConfirm"`
IsMechanismSub bool `json:"isMechanismSub"` //是否机构子账号
MechanismId int `json:"mechanismId"` //机构ID 用于标识机构登录机构账号操作
MechanismDomain []string `json:"mechanismDomain"` //所属机构domain
Organization int `json:"organization"` //所属机构ID
}
Click to show internal directories.
Click to hide internal directories.