Documentation ¶
Index ¶
- Constants
- func CaptureErrorToSentry(ctx *Context, err string)
- func CheckArgs(r RestResourceInterface, ctx *Context)
- func HandleStaticFile(path string, response *Response) bool
- func RecoverFromCronTaskPanic(ctx context.Context)
- func RecoverPanic(ctx *Context)
- type Context
- func (ctx *Context) AddEvent(eventData map[string]interface{})
- func (ctx *Context) EmitAll()
- func (ctx *Context) Get(key string) interface{}
- func (ctx *Context) GetBusinessContext() context.Context
- func (ctx *Context) Reset(rw http.ResponseWriter, r *http.Request)
- func (ctx *Context) Set(key string, value interface{})
- func (ctx *Context) SetBusinessContext(value interface{})
- func (ctx *Context) SetJSON(key string, value map[string]interface{})
- func (ctx *Context) SetJSONArray(key string, value []interface{})
- type FillOption
- type Map
- type Middleware
- type MiddlewareInterface
- type Request
- func (r *Request) GetBool(key string, def ...bool) (bool, error)
- func (r *Request) GetBoolOptions(key string) map[string]bool
- func (r *Request) GetFile(key string) (multipart.File, *multipart.FileHeader, error)
- func (r *Request) GetFillOptions(key string) FillOption
- func (r *Request) GetFilters() map[string]interface{}
- func (r *Request) GetFloat(key string, def ...float64) (float64, error)
- func (r *Request) GetInt(key string, def ...int) (int, error)
- func (r *Request) GetInt16(key string, def ...int16) (int16, error)
- func (r *Request) GetInt32(key string, def ...int32) (int32, error)
- func (r *Request) GetInt64(key string, def ...int64) (int64, error)
- func (r *Request) GetInt8(key string, def ...int8) (int8, error)
- func (r *Request) GetIntArray(key string) []int
- func (r *Request) GetJSON(key string) map[string]interface{}
- func (r *Request) GetJSONArray(key string) []interface{}
- func (r *Request) GetOrmFilters() map[string]interface{}
- func (r *Request) GetPageInfo() *paginate.PageInfo
- func (r *Request) GetString(key string, def ...string) string
- func (r *Request) GetStringArray(key string) []string
- func (r *Request) GetUint16(key string, def ...uint16) (uint16, error)
- func (r *Request) GetUint32(key string, def ...uint32) (uint32, error)
- func (r *Request) GetUint64(key string, def ...uint64) (uint64, error)
- func (r *Request) GetUint8(key string, def ...uint8) (uint8, error)
- func (r *Request) Header(key string) string
- func (r *Request) Input() url.Values
- func (r *Request) Method() string
- func (r *Request) Query(key string) string
- func (r *Request) RawMethod() string
- func (r *Request) Reset(request *http.Request)
- func (r *Request) SetFilter(key string, value interface{})
- func (r *Request) SetFilters(filters map[string]interface{})
- func (r *Request) SetJSON(key string, value map[string]interface{})
- func (r *Request) SetJSONArray(key string, value []interface{})
- func (r *Request) URL() string
- type Response
- func (r *Response) Body(content []byte) error
- func (r *Response) CloseNotify() <-chan bool
- func (r *Response) Content(content []byte, contentType string) error
- func (r *Response) Error(errCode string, errMsg string)
- func (r *Response) ErrorWithCode(code int, errCode string, errMsg string, innerErrMsg string)
- func (r *Response) Flush()
- func (r *Response) Header(key string, value string)
- func (r *Response) Hijack() (net.Conn, *bufio.ReadWriter, error)
- func (r *Response) JSON(data interface{})
- func (r *Response) JSONWithOption(data interface{}, hasIndent bool, coding bool) error
- func (r *Response) Reset(rw http.ResponseWriter)
- func (r *Response) Write(p []byte) (int, error)
- func (r *Response) WriteHeader(code int)
- type RestResource
- func (r *RestResource) Delete(ctx *Context)
- func (r *RestResource) EnableHTMLResource() bool
- func (r *RestResource) Get(ctx *Context)
- func (r *RestResource) GetParameters() map[string][]string
- func (r *RestResource) Head(ctx *Context)
- func (r *RestResource) Options(ctx *Context)
- func (r *RestResource) Patch(ctx *Context)
- func (r *RestResource) Post(ctx *Context)
- func (r *RestResource) Prepare(ctx *Context)
- func (r *RestResource) Put(ctx *Context)
- func (r *RestResource) Resource() string
- func (r *RestResource) SkipAuthCheck() bool
- type RestResourceInterface
- type RestResponse
Constants ¶
const SENTRY_CHANNEL_TIMEOUT = 50
Variables ¶
This section is empty.
Functions ¶
func CaptureErrorToSentry ¶
CapturePanicToSentry will collect error info then send to sentry
func CheckArgs ¶
func CheckArgs(r RestResourceInterface, ctx *Context)
CheckArgs: check whether param is right
func HandleStaticFile ¶
func RecoverFromCronTaskPanic ¶
RecoverFromCronTaskPanic crontask的recover
func RecoverPanic ¶
func RecoverPanic(ctx *Context)
Types ¶
type Context ¶
type Context struct { Request *Request Response *Response Data map[string]interface{} Events []map[string]interface{} }
func (*Context) GetBusinessContext ¶
func (*Context) Reset ¶
func (ctx *Context) Reset(rw http.ResponseWriter, r *http.Request)
Reset init Context
func (*Context) SetBusinessContext ¶
func (ctx *Context) SetBusinessContext(value interface{})
func (*Context) SetJSONArray ¶
type FillOption ¶
type Middleware ¶
type Middleware struct { }
func (*Middleware) ProcessRequest ¶
func (m *Middleware) ProcessRequest(ctx *Context)
func (*Middleware) ProcessResponse ¶
func (m *Middleware) ProcessResponse(ctx *Context)
type MiddlewareInterface ¶
type Request ¶
type Request struct { HttpRequest *http.Request Name2JSON map[string]map[string]interface{} Name2JSONArray map[string][]interface{} Filters map[string]interface{} }
Request
func (*Request) GetBool ¶
GetBool returns input value as bool or the default value while it's present and input is blank.
func (*Request) GetFillOptions ¶
func (r *Request) GetFillOptions(key string) FillOption
func (*Request) GetFilters ¶
func (*Request) GetFloat ¶
GetFloat returns input value as float64 or the default value while it's present and input is blank.
func (*Request) GetInt ¶
GetInt returns input as an int or the default value while it's present and input is blank
func (*Request) GetInt16 ¶
GetInt16 returns input as an int16 or the default value while it's present and input is blank
func (*Request) GetInt32 ¶
GetInt32 returns input as an int32 or the default value while it's present and input is blank
func (*Request) GetInt64 ¶
GetInt64 returns input value as int64 or the default value while it's present and input is blank.
func (*Request) GetInt8 ¶
GetInt8 return input as an int8 or the default value while it's present and input is blank
func (*Request) GetIntArray ¶
func (*Request) GetJSONArray ¶
GetJSONArray 与key对应的返回json array数据
func (*Request) GetOrmFilters ¶
func (*Request) GetPageInfo ¶
func (*Request) GetStringArray ¶
func (*Request) GetUint16 ¶
GetUint16 returns input as an uint16 or the default value while it's present and input is blank
func (*Request) GetUint32 ¶
GetUint32 returns input as an uint32 or the default value while it's present and input is blank
func (*Request) GetUint64 ¶
GetUint64 returns input value as uint64 or the default value while it's present and input is blank.
func (*Request) GetUint8 ¶
GetUint8 return input as an uint8 or the default value while it's present and input is blank
func (*Request) SetFilters ¶
func (*Request) SetJSONArray ¶
type Response ¶
type Response struct { ResponseWriter http.ResponseWriter Started bool Status int ContentLength int ErrCode string ErrMsg string }
Response is a wrapper for the http.ResponseWriter started set to true if response was written to then don't execute other handler
func (*Response) CloseNotify ¶
CloseNotify http.CloseNotifier
func (*Response) ErrorWithCode ¶
func (*Response) JSONWithOption ¶
func (*Response) Reset ¶
func (r *Response) Reset(rw http.ResponseWriter)
func (*Response) Write ¶
Write writes the data to the connection as part of an HTTP reply, and sets `started` to true. started means the response has sent out.
func (*Response) WriteHeader ¶
WriteHeader sends an HTTP response header with status code, and sets `started` to true.
type RestResource ¶
RestResource 扩展eel.Controller, 作为rest中各个资源的基类
func (*RestResource) Delete ¶
func (r *RestResource) Delete(ctx *Context)
Delete adds a request function to handle DELETE request.
func (*RestResource) EnableHTMLResource ¶
func (r *RestResource) EnableHTMLResource() bool
EnableHTMLResource 是否开启html资源
func (*RestResource) Get ¶
func (r *RestResource) Get(ctx *Context)
Get adds a request function to handle GET request.
func (*RestResource) GetParameters ¶
func (r *RestResource) GetParameters() map[string][]string
Parameters 获取需要检查的参数
func (*RestResource) Head ¶
func (r *RestResource) Head(ctx *Context)
Head adds a request function to handle HEAD request.
func (*RestResource) Options ¶
func (r *RestResource) Options(ctx *Context)
Options adds a request function to handle OPTIONS request.
func (*RestResource) Patch ¶
func (r *RestResource) Patch(ctx *Context)
Patch adds a request function to handle PATCH request.
func (*RestResource) Post ¶
func (r *RestResource) Post(ctx *Context)
Post adds a request function to handle POST request.
func (*RestResource) Prepare ¶
func (r *RestResource) Prepare(ctx *Context)
prepare for request handling
func (*RestResource) Put ¶
func (r *RestResource) Put(ctx *Context)
Put adds a request function to handle PUT request.
func (*RestResource) Resource ¶
func (r *RestResource) Resource() string
func (*RestResource) SkipAuthCheck ¶
func (r *RestResource) SkipAuthCheck() bool
type RestResourceInterface ¶
type RestResourceInterface interface { //Init(ct *handler.Context, controllerName, actionName string, app interface{}) Prepare(ctx *Context) Get(ctx *Context) Post(ctx *Context) Delete(ctx *Context) Put(ctx *Context) //Finish(ctx *Context) Resource() string //EnableHTMLResource() bool GetParameters() map[string][]string SkipAuthCheck() bool }
type RestResponse ¶
type RestResponse struct { Code int32 `json:"code"` Data interface{} `json:"data"` ErrCode string `json:"errCode"` ErrMsg string `json:"errMsg"` InnerErrMsg string `json:"innerErrMsg"` }
func MakeErrorResponse ¶
func MakeErrorResponse(code int32, errCode string, errMsg string, innerErrMsgs ...string) *RestResponse
func MakeResponse ¶
func MakeResponse(data interface{}) *RestResponse