ginx

package module
v0.0.0-...-fce6733 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const (
	GIN_RequestId = "GIN_RequestId"
	GIN_Error     = "GIN_Error"
	GIN_Identity  = "GIN_Identity" // string
	GIN_Data      = "GIN_Data"     // map[string]any
)

Variables

This section is empty.

Functions

func APILog

func APILog(lgg *zap.Logger, name string, skip int) gin.HandlerFunc

skip = 5

func BasicAuth

func BasicAuth(username, password string, handle func(*gin.Context, string)) gin.HandlerFunc

handle key: no_token, invalid_token, incorrect_token, User:XXXX

func BasicBcrypt

func BasicBcrypt(username, password string, handle func(*gin.Context, ...string)) gin.HandlerFunc

handle key: no_token, invalid_token, incorrect_token, User:XXXX

func CacheControl

func CacheControl(seconds int) gin.HandlerFunc

func Cors

func Cors(origin string) gin.HandlerFunc

func Get

func Get[T any](ctx *gin.Context, key string) (item T, err error)

errors: value is unset, type not match

func GetDate

func GetDate(ctx *gin.Context) (*time.Time, error)

func Healthz

func Healthz(ctx *gin.Context)

func IndexStaticFiles

func IndexStaticFiles(router *gin.RouterGroup, d string) (err error)

func ServeStaticDir

func ServeStaticDir(httpDir, local string, listDir bool) func(*gin.RouterGroup)

func ServeStaticFile

func ServeStaticFile(bts []byte, name string) gin.HandlerFunc

name: filename, e.g. favicon.ico ct: Content-Type, e.g. image/x-icon

func SetData

func SetData(ctx *gin.Context, kvs map[string]any)

func SetError

func SetError(ctx *gin.Context, err any)

func SetIdentity

func SetIdentity(ctx *gin.Context, kvs map[string]string)

func SetRequestId

func SetRequestId(ctx *gin.Context, requestId string)

func WsUpgrade

func WsUpgrade(ctx *gin.Context)

Types

type HttpConfig

type HttpConfig struct {
	Path string `mapstructure:"path"`
	Cors string `mapstructure:"cors"`
	Tls  bool   `mapstructure:"tls"`
	Cert string `mapstructure:"cert"`
	Key  string `mapstructure:"key"`
}

func (*HttpConfig) FromFile

func (self *HttpConfig) FromFile(fp string) (err error)

func (*HttpConfig) SetEngine

func (self *HttpConfig) SetEngine(engine *gin.Engine)

func (*HttpConfig) SetServer

func (self *HttpConfig) SetServer(server *http.Server) (err error)

Jump to

Keyboard shortcuts

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