Documentation ¶
Index ¶
- func CtxRemoteIpGet(c *gin.Context) string
- func CtxRemoteIpSet(c *gin.Context, ip string)
- func CtxRequestGet(c *gin.Context) any
- func CtxRequestSet(c *gin.Context, req any)
- func CtxResponseSet(c *gin.Context, rsp *Response)
- func CtxUserIdGet(c *gin.Context) core.TUserID
- func CtxUserIdSet(c *gin.Context, uid core.TUserID)
- func CtxUserNameGet(c *gin.Context) string
- func CtxUserNameSet(c *gin.Context, name string)
- func GetRunMode() string
- func Install(conf *Config) ctl.IControler
- func Observe(callback TObserveCallBack)
- func Register(r IGroupRouter)
- func RegisterRender(r IRender)
- func Service(c *gin.Context, s IService)
- func SetRunMode(mode string)
- type Config
- type ECode
- type ESRenderMode
- type GinLogger
- type GinRecover
- type GroupRouter
- type IContrler
- type IGroupRouter
- type IRender
- type ISRenderModer
- type IService
- type ListenTLS
- type Response
- func CtxResponseGet(c *gin.Context) *Response
- func RespBindErr(err error) Response
- func RespData[T util.IntStringer](code T, msg string, data any) Response
- func RespErr[T util.IntStringer](code T, msg string, err error) Response
- func RespFile(c *gin.Context, filePath string) Response
- func RespLogicErr(msg string, err error) Response
- func RespMDBErr(msg string, err error) Response
- func RespOK(msg string, data any) Response
- func RespParamErr(msg string, err error) Response
- func RespRDBErr(msg string, err error) Response
- func RespSysErr(msg string, err error) Response
- type TObserveCallBack
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CtxRemoteIpGet ¶
CtxRemoteIpGet get remote_ip from Context
func CtxRemoteIpSet ¶
CtxRemoteIpSet set remote_ip to Context (业务层设置)
func CtxRequestSet ¶
CtxRequestSet set request to Context (系统内部或中间件设置)
func CtxResponseSet ¶
CtxGetResponse set response to Context (系统内部或中间件设置)
func CtxUserIdSet ¶
CtxUserIdSet 设置user_id (业务层设置)
func CtxUserNameSet ¶
CtxUserNameSet 设置user_name (业务层设置)
func GetRunMode ¶
func GetRunMode() string
func RegisterRender ¶
func RegisterRender(r IRender)
Types ¶
type Config ¶
type Config struct { RunMode string `json:"runMode"` // debug release ListenAddr string `json:"listenAddr"` WriteTimeout int `json:"writeTimeout"` // second ReadTimeout int `json:"readTimeout"` // second ListnTls ListenTLS `json:"listnTls"` }
> 配置项
type ECode ¶
type ECode int //
> 错误码类型
const ( ECodeSucessed ECode = 0 // http.StatusOK ECodeSysError ECode = 501 // 系统错误 ECodeParamErr ECode = 502 // 参数错误 ECodeMDBError ECode = 503 // 数据库错误 ECodeRDBError ECode = 504 // 缓存库错误 ECodeCodeCrypt ECode = 505 // 编码加密错误 ECodeLogicErr ECode = 506 // 逻辑错误 ECodeExtendBegin1000 ECode = 1000 // 业务扩展起始编号 )
type ESRenderMode ¶
type ESRenderMode int //
> 路由服务渲染模式
const ( ESRender_None ESRenderMode = iota // 以xml数据格式返回 ESRender_Xml // 以xml数据格式返回 ESRender_Yaml // 以yaml数据格式返回 ESRender_Json // 以JSON数据格式返回 ESRender_Pbuf // 以Protobuf数据格式返回 )
func (ESRenderMode) String ¶
func (e ESRenderMode) String() string
type GroupRouter ¶
type GroupRouter struct {
*gin.RouterGroup
}
> GroupRouter
func (*GroupRouter) API ¶
func (gr *GroupRouter) API(group *gin.RouterGroup, relativePath string, service IService, otherHandlers ...gin.HandlerFunc)
注册API接口服务(GET|POST)
type IContrler ¶
type IContrler interface { ctl.IControler }
> 控制器接口
var (
Ctl IContrler // 默认htp控制器
)
func Controller ¶
type IGroupRouter ¶
type IGroupRouter interface { // 模块名称 Name() string // 返回["", ".", "/"], 则表示 root router // 初始化路由 Init(group *GroupRouter) }
> 路由接口
type IRender ¶
type IRender interface { // 模式 Mode() ESRenderMode // 渲染 Render(c *gin.Context, status int, rsp *Response) }
> render接口
func MakeRender ¶
func MakeRender(mode ESRenderMode) IRender
type Response ¶
type Response struct { Code int `json:"code" xml:"code" yaml:"code"` Data any `json:"data,omitempty" xml:"data,omitempty" yaml:"data,omitempty"` Msg string `json:"msg" xml:"msg" yaml:"msg"` Error string `json:"err,omitempty" xml:"err,omitempty" yaml:"err,omitempty"` // code_string : error_info // contains filtered or unexported fields }
Response 基础序列化器
func CtxResponseGet ¶
CtxResponseGet get response from Context
Source Files ¶
Click to show internal directories.
Click to hide internal directories.