Documentation
¶
Index ¶
- Constants
- type BusinessError
- type Context
- type HandlerFunc
- type Mux
- type Router
- func (r *Router) Any(relativePath string, handlers ...HandlerFunc)
- func (r *Router) DELETE(relativePath string, handlers ...HandlerFunc)
- func (r *Router) GET(relativePath string, handlers ...HandlerFunc)
- func (r *Router) GET_Gin(relativePath string, handlers []gin.HandlerFunc)
- func (r *Router) PATCH(relativePath string, handlers ...HandlerFunc)
- func (r *Router) POST(relativePath string, handlers ...HandlerFunc)
- func (r *Router) POST_Gin(relativePath string, handlers []gin.HandlerFunc)
- func (r *Router) PUT(relativePath string, handlers ...HandlerFunc)
- func (r *Router) Use(middleware HandlerFunc) *Router
Constants ¶
View Source
const (
UserIDKey = "_user_id_"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BusinessError ¶
type BusinessError interface {
// WithError setting error message
WithStack(err error) BusinessError
// BusinessCode get business code
BusinessCode() string
// HTTPCode get the HTTP status code
HTTPCode() int
// Message get the error description
Message() string
// StackError get the error message with stack
StackError() error
Error() string
}
func Error ¶
func Error(businessCode, message string) BusinessError
type Context ¶
type Context interface {
ShouldBind(obj interface{}) error
// ShouldBindQuery deserialization querystring
// tag: `form:"xxx"`(note: do not write query)
ShouldBindQuery(obj interface{}) error
// ShouldBindPostForm deserialization postform (querystring will be ignored)
// tag: `form:"xxx"`
ShouldBindPostForm(obj interface{}) error
// ShouldBindJSON deserialization postjson
// tag: `json:"xxx"`
ShouldBindJSON(obj interface{}) error
// ShouldBindURI the deserialization path parameter (if the routing path is/user/:name)
// tag: `uri:"xxx"`
ShouldBindURI(obj interface{}) error
Param(key string) string
// Payload returned correctly
GetMethodPath() (method string, path string)
// Payload 正确返回
Payload(payload interface{})
// AbortWithError error return
AbortWithPermissionError(err error, expectCode string, emptyResp any)
// c.AbortWithError(
// http.StatusBadRequest,
// code.ParamBindError,
// err,
// )
// AbortWithError(err BusinessError)
// If err is BusinessError, param businessCode will be ignored
AbortWithError(statusCode int, businessCode string, err error)
// Header Gets the Header object
Header() http.Header
// Get the header GetHeader
GetHeader(key string) string
// Set the header SetHeader
SetHeader(key, value string)
GetContext() go_context.Context
// Set Sets key-value pairs in context
Set(key string, value interface{})
// Get Gets the value of the key in context.
Get(key string) (any, bool)
Next()
Request() *http.Request
ClientIP() string
LANG() string
UserID() int64
ErrMessage(errCode string) string
Clone() Context
Done() <-chan struct{}
Err() error
Value(key any) any
Deadline() (deadline time.Time, ok bool)
// contains filtered or unexported methods
}
type HandlerFunc ¶
type HandlerFunc func(c Context)
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) Any ¶
func (r *Router) Any(relativePath string, handlers ...HandlerFunc)
func (*Router) DELETE ¶
func (r *Router) DELETE(relativePath string, handlers ...HandlerFunc)
func (*Router) GET ¶
func (r *Router) GET(relativePath string, handlers ...HandlerFunc)
func (*Router) PATCH ¶
func (r *Router) PATCH(relativePath string, handlers ...HandlerFunc)
func (*Router) POST ¶
func (r *Router) POST(relativePath string, handlers ...HandlerFunc)
func (*Router) POST_Gin ¶
func (r *Router) POST_Gin(relativePath string, handlers []gin.HandlerFunc)
func (*Router) PUT ¶
func (r *Router) PUT(relativePath string, handlers ...HandlerFunc)
func (*Router) Use ¶
func (r *Router) Use(middleware HandlerFunc) *Router
Click to show internal directories.
Click to hide internal directories.