Documentation ¶
Index ¶
- Constants
- Variables
- func IsRespError(err error) bool
- func IsSuccess(err RespError) bool
- func SetLogOutput(out io.Writer)
- func SetupSignalHandler() context.Context
- type EasyGin
- func (e *EasyGin) DELETE(relativePath string, handlers ...Handler)
- func (e *EasyGin) GET(relativePath string, handlers ...Handler)
- func (e *EasyGin) Group(relativePath string, handlers ...Handler) *RouterGroup
- func (e *EasyGin) HEAD(relativePath string, handlers ...Handler)
- func (e *EasyGin) ListenAndServe(addr string) error
- func (e *EasyGin) PATCH(relativePath string, handlers ...Handler)
- func (e *EasyGin) POST(relativePath string, handlers ...Handler)
- func (e *EasyGin) PUT(relativePath string, handlers ...Handler)
- func (e *EasyGin) SetAfterCloseHandlers(handlers ...func())
- func (e *EasyGin) SetMaxGraceDuration(max time.Duration)
- func (e *EasyGin) SetSignalHandler(f func() context.Context)
- type Handler
- type Profile
- type RespError
- type RespErrorImpl
- type RespValue
- type Response
- func Error(status int) *Response
- func Fail(respErr RespError) *Response
- func FailData(respErr RespError, data interface{}) *Response
- func NewResponse(status int, data interface{}, respErr RespError) *Response
- func Ok() *Response
- func OkCode(code int) *Response
- func OkCodeData(code int, data interface{}) *Response
- func OkData(data interface{}) *Response
- type RouterGroup
- func (r *RouterGroup) DELETE(relativePath string, handlers ...Handler)
- func (r *RouterGroup) GET(relativePath string, handlers ...Handler)
- func (r *RouterGroup) HEAD(relativePath string, handlers ...Handler)
- func (r *RouterGroup) PATCH(relativePath string, handlers ...Handler)
- func (r *RouterGroup) POST(relativePath string, handlers ...Handler)
- func (r *RouterGroup) PUT(relativePath string, handlers ...Handler)
- type Stopper
Constants ¶
View Source
const ( UnknownErrorCode = -1 SuccessCode = 0 )
View Source
const (
ContentTypeJson = "application/json"
)
View Source
const DefaultMemProfileRate = 4096
Variables ¶
View Source
var ( RespSuccess = RespError(&RespErrorImpl{ Codee: SuccessCode, Messagee: "success", }) )
Functions ¶
func IsRespError ¶
func SetLogOutput ¶
func SetupSignalHandler ¶
Types ¶
type EasyGin ¶
func NewWithEngine ¶
func (*EasyGin) Group ¶
func (e *EasyGin) Group(relativePath string, handlers ...Handler) *RouterGroup
func (*EasyGin) ListenAndServe ¶
func (*EasyGin) SetAfterCloseHandlers ¶
func (e *EasyGin) SetAfterCloseHandlers(handlers ...func())
SetAfterCloseHandlers register handlers which will be called after server closed
func (*EasyGin) SetMaxGraceDuration ¶
func (*EasyGin) SetSignalHandler ¶
SetSignalHandler set signal processing functions if the signal processing function is set when calling this method, the registered afterCloseHandlers will not work
type Handler ¶
type Handler interface{}
Handler must be in one of the following forms func(ctx *gin.Context) *Response func(ctx *gin.Context, u UserType) *Response must have one or two parameter first param: must be *gin.Context second param: must be a struct or a pointer of struct return value must be *Response
type RespErrorImpl ¶
RespErrorImpl e is added at the end because we need to export the field and it cannot have the same name as the function
func (*RespErrorImpl) Code ¶
func (e *RespErrorImpl) Code() int
func (*RespErrorImpl) Error ¶
func (e *RespErrorImpl) Error() string
func (*RespErrorImpl) Message ¶
func (e *RespErrorImpl) Message() string
type RespValue ¶
type RespValue struct { RespError Data interface{} `json:"data"` }
func (*RespValue) MarshalJSON ¶
type RouterGroup ¶
type RouterGroup struct {
*gin.RouterGroup
}
func (*RouterGroup) DELETE ¶
func (r *RouterGroup) DELETE(relativePath string, handlers ...Handler)
func (*RouterGroup) GET ¶
func (r *RouterGroup) GET(relativePath string, handlers ...Handler)
func (*RouterGroup) HEAD ¶
func (r *RouterGroup) HEAD(relativePath string, handlers ...Handler)
func (*RouterGroup) PATCH ¶
func (r *RouterGroup) PATCH(relativePath string, handlers ...Handler)
func (*RouterGroup) POST ¶
func (r *RouterGroup) POST(relativePath string, handlers ...Handler)
func (*RouterGroup) PUT ¶
func (r *RouterGroup) PUT(relativePath string, handlers ...Handler)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.