Documentation ¶
Index ¶
- func ClientIP(c *gin.Context) string
- func CreateToken(appId string, openid int64) (tokenStr string, err error)
- func GrpcContext(c *gin.Context) context.Context
- func Handler(controller iController) gin.HandlerFunc
- func LoadJsonConfig(jsonFile string, conf interface{}) (err error)
- func LoadYamlConfig(yamlFile string, conf interface{}) (err error)
- func RequestBody(c *gin.Context) interface{}
- func RequestId(c *gin.Context) string
- func ValidationMessage(err error, messages map[string]string) string
- type Config
- type Encryption
- type LocalUpload
- type Option
- func CorsHeaderOption(corsHeaders ...string) Option
- func EnableEncryptionOption(encryptKey, encryptSecret string, excludeUris ...string) Option
- func EnvOption(env goio.Environment) Option
- func NoAccessPathsOption(noAccessPaths ...string) Option
- func NoLogPathsOption(noLogPaths ...string) Option
- func PProfEnableOption(pprofEnable bool) Option
- func ServerNameOption(serverName string) Option
- type Response
- func Error(code int32, message string, v ...interface{}) *Response
- func ErrorResponse(err *goerror.CodeError) *Response
- func ErrorResponseX(errorCode string, errorMessage string, showType ...uint32) *Response
- func ErrorWithValidate(err error, messages map[string]string) *Response
- func HttpBadRequest(msg string, showType ...uint32) *Response
- func HttpFailForCode(code int64, msg string, showType ...uint32) *Response
- func HttpForbidden(msg string, showType ...uint32) *Response
- func HttpNotFound(msg string, showType ...uint32) *Response
- func HttpServerError(msg string, showType ...uint32) *Response
- func HttpSuccess(data interface{}) *Response
- func HttpUnauthorized(msg string, showType ...uint32) *Response
- func SuccessResponse(data any) *Response
- type ResponseBuilder
- func (b *ResponseBuilder) Build() *Response
- func (b *ResponseBuilder) WithData(data any) *ResponseBuilder
- func (b *ResponseBuilder) WithErrorCode(errorCode string) *ResponseBuilder
- func (b *ResponseBuilder) WithErrorMessage(errorMessage string) *ResponseBuilder
- func (b *ResponseBuilder) WithHost(host string) *ResponseBuilder
- func (b *ResponseBuilder) WithShowType(showType uint32) *ResponseBuilder
- func (b *ResponseBuilder) WithSuccess(success bool) *ResponseBuilder
- func (b *ResponseBuilder) WithTraceId(traceId string) *ResponseBuilder
- type Server
- type Token
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateToken ¶ added in v1.2.95
func LoadJsonConfig ¶ added in v1.2.95
func LoadYamlConfig ¶ added in v1.2.95
Types ¶
type Config ¶ added in v1.2.95
type Config struct { Env goio.Environment `yaml:"env"` Server struct { Addr string `yaml:"addr"` Name string `yaml:"name"` } `yaml:"server"` Prometheus prometheusx.Config `yaml:"prometheus"` MongoDB gomongo.Config `yaml:"mongodb"` Mysql gogorm.Config `yaml:"mysql"` Postgres gogorm.Config `yaml:"postgres"` Sqlite gogorm.Config `yaml:"sqlite"` Clickhouse1 gogorm.Config `yaml:"clickhouse1"` Redis goredis.Config `yaml:"redis"` Kafka gokafka.Config `yaml:"kafka"` Clickhouse goclickhouse.Config `yaml:"clickhouse"` Es goes.Config `yaml:"es"` Etcd goetcd.Config `yaml:"etcd"` FeiShu string `yaml:"feishu"` }
type Encryption ¶ added in v1.2.95
type LocalUpload ¶ added in v1.2.95
type LocalUpload struct { }
type Option ¶ added in v1.2.95
type Option interface {
// contains filtered or unexported methods
}
func EnableEncryptionOption ¶ added in v1.2.95
启用加密传输
func NoAccessPathsOption ¶ added in v1.2.95
禁止访问的path
func NoLogPathsOption ¶ added in v1.2.95
不记录日志的path
type Response ¶ added in v1.2.95
type Response struct { Success bool `json:"success"` Data any `json:"data"` ErrorCode string `json:"errorCode"` ErrorMessage string `json:"errorMessage"` ShowType uint32 `json:"showType"` TraceId string `json:"traceId"` Host string `json:"host"` }
func ErrorResponse ¶ added in v1.2.177
func ErrorResponseX ¶ added in v1.2.179
便捷方法: 快速创建错误响应
func ErrorWithValidate ¶ added in v1.2.95
func HttpBadRequest ¶ added in v1.2.178
请求格式错误,比如参数格式、参数字段名等 不正确
func HttpFailForCode ¶ added in v1.2.178
如需返回特殊错误码,调用此接口
func HttpForbidden ¶ added in v1.2.178
用户已进行身份认证,但权限不够
func HttpNotFound ¶ added in v1.2.178
接口不存在
func HttpServerError ¶ added in v1.2.178
服务器内部错误
func HttpUnauthorized ¶ added in v1.2.178
用户没有访问权限,需要进行身份认证
type ResponseBuilder ¶ added in v1.2.177
type ResponseBuilder struct {
// contains filtered or unexported fields
}
ResponseBuilder 是 Response 的构建器
func NewResponseBuilder ¶ added in v1.2.177
func NewResponseBuilder() *ResponseBuilder
NewResponseBuilder 创建一个新的 Response 构建器
func (*ResponseBuilder) Build ¶ added in v1.2.177
func (b *ResponseBuilder) Build() *Response
Build 构建并返回最终的 Response 对象
func (*ResponseBuilder) WithData ¶ added in v1.2.177
func (b *ResponseBuilder) WithData(data any) *ResponseBuilder
WithData 设置数据
func (*ResponseBuilder) WithErrorCode ¶ added in v1.2.177
func (b *ResponseBuilder) WithErrorCode(errorCode string) *ResponseBuilder
WithErrorCode 设置错误代码
func (*ResponseBuilder) WithErrorMessage ¶ added in v1.2.177
func (b *ResponseBuilder) WithErrorMessage(errorMessage string) *ResponseBuilder
WithErrorMessage 设置错误信息
func (*ResponseBuilder) WithHost ¶ added in v1.2.177
func (b *ResponseBuilder) WithHost(host string) *ResponseBuilder
WithHost 设置主机信息
func (*ResponseBuilder) WithShowType ¶ added in v1.2.177
func (b *ResponseBuilder) WithShowType(showType uint32) *ResponseBuilder
WithShowType 设置显示类型
func (*ResponseBuilder) WithSuccess ¶ added in v1.2.177
func (b *ResponseBuilder) WithSuccess(success bool) *ResponseBuilder
WithSuccess 设置成功状态
func (*ResponseBuilder) WithTraceId ¶ added in v1.2.177
func (b *ResponseBuilder) WithTraceId(traceId string) *ResponseBuilder
WithTraceId 设置追踪ID
Click to show internal directories.
Click to hide internal directories.