Documentation ¶
Index ¶
- Constants
- Variables
- type BaseController
- func (this *BaseController) AddLog(k string, v interface{})
- func (this *BaseController) Cost() int64
- func (this *BaseController) GenLog() map[string]interface{}
- func (this *BaseController) GetArray(key string) []string
- func (this *BaseController) GetBool(key string, defaultValues ...bool) bool
- func (this *BaseController) GetCookie(key string) string
- func (this *BaseController) GetErrorResponse(err interface{}) (int, string, map[string]interface{})
- func (this *BaseController) GetFile(key string) (multipart.File, *multipart.FileHeader, error)
- func (this *BaseController) GetHeader(key string) string
- func (this *BaseController) GetInt(key string, defaultValues ...int) int
- func (this *BaseController) GetInt64(key string, defaultValues ...int64) int64
- func (this *BaseController) GetIp() string
- func (this *BaseController) GetMap(key string) lib.MAP
- func (this *BaseController) GetParams() map[string]string
- func (this *BaseController) GetRequestUri() string
- func (this *BaseController) GetRpcContent() string
- func (this *BaseController) GetSlice(key string, separators ...string) []string
- func (this *BaseController) GetSliceInt(key string, separators ...string) []int
- func (this *BaseController) GetString(key string, defaultValues ...string) string
- func (this *BaseController) GetUA() string
- func (this *BaseController) Init()
- func (this *BaseController) OmitLog(v string)
- func (this *BaseController) Prepare(rw http.ResponseWriter, r *http.Request, controller, action string)
- func (this *BaseController) PrepareCli(r url.Values, controller, action string)
- func (this *BaseController) PrepareRpc(r url.Values, ctx context.Context, controller, action string)
- func (this *BaseController) Redirect(url string, codes ...int)
- func (this *BaseController) Render(data ...interface{})
- func (this *BaseController) RenderError(err interface{})
- func (this *BaseController) RenderHtml(file string)
- func (this *BaseController) RenderJson(json string)
- func (this *BaseController) RenderResponser(errno, errmsg, retdata interface{}) string
- func (this *BaseController) RenderStatus(code int)
- func (this *BaseController) RenderString(data string)
- func (this *BaseController) SetCookie(key, val string, lifetime int, options ...interface{})
- func (this *BaseController) SetHeader(key, val string)
- func (this *BaseController) SetHeaders(headers http.Header)
Constants ¶
View Source
const ( HTTP_MODE = iota RPC_MODE CLI_MODE )
Variables ¶
View Source
var ( DEBUG = false LOG_ACCESS = true LOG_ERROR = true )
Functions ¶
This section is empty.
Types ¶
type BaseController ¶
type BaseController struct { RW http.ResponseWriter R *http.Request RBody []byte IR *iRequest Ctx context.Context Mode int Controller string Action string Uri string Debug bool // contains filtered or unexported fields }
func (*BaseController) AddLog ¶
func (this *BaseController) AddLog(k string, v interface{})
在业务日志中添加自定义字段
func (*BaseController) Cost ¶
func (this *BaseController) Cost() int64
func (*BaseController) GetArray ¶
func (this *BaseController) GetArray(key string) []string
获取数组类型参数
func (*BaseController) GetBool ¶
func (this *BaseController) GetBool(key string, defaultValues ...bool) bool
获取bool型参数
func (*BaseController) GetCookie ¶
func (this *BaseController) GetCookie(key string) string
以下 GetX 方法用于获取参数
func (*BaseController) GetErrorResponse ¶
func (this *BaseController) GetErrorResponse(err interface{}) (int, string, map[string]interface{})
根据捕获的错误获取需要返回的错误码、错误信息及数据
func (*BaseController) GetFile ¶
func (this *BaseController) GetFile(key string) (multipart.File, *multipart.FileHeader, error)
获取上传文件
func (*BaseController) GetHeader ¶
func (this *BaseController) GetHeader(key string) string
func (*BaseController) GetInt ¶
func (this *BaseController) GetInt(key string, defaultValues ...int) int
获取Int型参数
func (*BaseController) GetInt64 ¶
func (this *BaseController) GetInt64(key string, defaultValues ...int64) int64
func (*BaseController) GetIp ¶
func (this *BaseController) GetIp() string
func (*BaseController) GetMap ¶
func (this *BaseController) GetMap(key string) lib.MAP
获取json字符串并转换为MAP
func (*BaseController) GetRequestUri ¶
func (this *BaseController) GetRequestUri() string
func (*BaseController) GetRpcContent ¶
func (this *BaseController) GetRpcContent() string
func (*BaseController) GetSlice ¶
func (this *BaseController) GetSlice(key string, separators ...string) []string
获取指定字符连接的字符串并转换成[]string
func (*BaseController) GetSliceInt ¶
func (this *BaseController) GetSliceInt(key string, separators ...string) []int
获取指定字符连接的字符串并转换成[]int
func (*BaseController) GetString ¶
func (this *BaseController) GetString(key string, defaultValues ...string) string
获取string类型参数
func (*BaseController) GetUA ¶
func (this *BaseController) GetUA() string
func (*BaseController) OmitLog ¶
func (this *BaseController) OmitLog(v string)
在业务日志中删除字段(比如密码等敏感字段)
func (*BaseController) Prepare ¶
func (this *BaseController) Prepare(rw http.ResponseWriter, r *http.Request, controller, action string)
func (*BaseController) PrepareCli ¶
func (this *BaseController) PrepareCli(r url.Values, controller, action string)
func (*BaseController) PrepareRpc ¶
func (*BaseController) Redirect ¶
func (this *BaseController) Redirect(url string, codes ...int)
重定向URL
func (*BaseController) Render ¶
func (this *BaseController) Render(data ...interface{})
接口正常输出json, 若要改变返回json格式,可在业务代码中重写此方法
func (*BaseController) RenderError ¶
func (this *BaseController) RenderError(err interface{})
接口异常输出json,在HttpApiServer中回调, 若要改变返回json格式,可在业务代码中重写此方法
func (*BaseController) RenderHtml ¶
func (this *BaseController) RenderHtml(file string)
func (*BaseController) RenderResponser ¶
func (this *BaseController) RenderResponser(errno, errmsg, retdata interface{}) string
格式化输出
func (*BaseController) SetCookie ¶
func (this *BaseController) SetCookie(key, val string, lifetime int, options ...interface{})
lifetime<0时删除cookie options: domain,secure,httponly,path
func (*BaseController) SetHeader ¶
func (this *BaseController) SetHeader(key, val string)
func (*BaseController) SetHeaders ¶
func (this *BaseController) SetHeaders(headers http.Header)
Click to show internal directories.
Click to hide internal directories.