goserver

package
v1.2.133 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientIP added in v1.2.95

func ClientIP(c *gin.Context) string

客户端IP

func CreateToken added in v1.2.95

func CreateToken(appId string, openid int64) (tokenStr string, err error)

func GrpcContext added in v1.2.95

func GrpcContext(c *gin.Context) context.Context

func Handler added in v1.2.95

func Handler(controller iController) gin.HandlerFunc

定义控制器调用实现

func LoadJsonConfig added in v1.2.95

func LoadJsonConfig(jsonFile string, conf interface{}) (err error)

func LoadYamlConfig added in v1.2.95

func LoadYamlConfig(yamlFile string, conf interface{}) (err error)

func RequestBody added in v1.2.95

func RequestBody(c *gin.Context) interface{}

请求数据

func RequestId added in v1.2.95

func RequestId(c *gin.Context) string

唯一ID

func ValidationMessage added in v1.2.95

func ValidationMessage(err error, messages map[string]string) string

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 Encryption struct {
	Key    string
	Secret string
}

func (*Encryption) Decode added in v1.2.95

func (enc *Encryption) Decode(str string) (b []byte, err error)

func (*Encryption) Encode added in v1.2.95

func (enc *Encryption) Encode(b []byte) (str string, err error)

type LocalUpload added in v1.2.95

type LocalUpload struct {
}

func (LocalUpload) Upload added in v1.2.95

func (lu LocalUpload) Upload(c *gin.Context, uploadDir string) *Response

type Option added in v1.2.95

type Option interface {
	// contains filtered or unexported methods
}

func CorsHeaderOption added in v1.2.95

func CorsHeaderOption(corsHeaders ...string) Option

跨域

func EnableEncryptionOption added in v1.2.95

func EnableEncryptionOption(encryptKey, encryptSecret string, excludeUris ...string) Option

启用加密传输

func EnvOption added in v1.2.95

func EnvOption(env goio.Environment) Option

运行环境

func NoAccessPathsOption added in v1.2.95

func NoAccessPathsOption(noAccessPaths ...string) Option

禁止访问的path

func NoLogPathsOption added in v1.2.95

func NoLogPathsOption(noLogPaths ...string) Option

不记录日志的path

func PProfEnableOption added in v1.2.95

func PProfEnableOption(pprofEnable bool) Option

开启分析

func ServerNameOption added in v1.2.95

func ServerNameOption(serverName string) Option

服务名称

type Response added in v1.2.95

type Response struct {
	Code    int32         `json:"code"`
	Message string        `json:"message"`
	Data    interface{}   `json:"data"`
	Errors  []interface{} `json:"-"`
}

func Error added in v1.2.95

func Error(code int32, message string, v ...interface{}) *Response

func ErrorWithValidate added in v1.2.95

func ErrorWithValidate(err error, messages map[string]string) *Response

func Success added in v1.2.95

func Success(data interface{}) *Response

func (*Response) Copy added in v1.2.95

func (rsp *Response) Copy() *Response

func (*Response) String added in v1.2.95

func (rsp *Response) String() string

type Server added in v1.2.95

type Server struct {
	*gin.Engine
}

自己定义web服务

func NewServer added in v1.2.95

func NewServer(opt ...Option) *Server

func (*Server) Run added in v1.2.95

func (s *Server) Run(addr string)

启动服务

type Token added in v1.2.95

type Token struct {
	AppId     string `json:"app_id"`
	OpenId    int64  `json:"data"`
	NonceStr  string `json:"nonce"`
	Timestamp int64  `json:"ts"`
}

func ParseToken added in v1.2.95

func ParseToken(tokenStr, appId string) (token *Token, err error)

func (*Token) Bytes added in v1.2.95

func (t *Token) Bytes() []byte

func (*Token) String added in v1.2.95

func (t *Token) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL