Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Captcha = captcha. New(). Init(func(c *captcha.Captcha) { c.Secret = "7658388" c.URLPrefix = "/captcha" })
Captcha plugin init
View Source
var Delivery = delivery.New()
Delivery Upload, Logger, Captcha Plugin init
View Source
var Identify = identify. New(). AddOptions(identify.FakeURLsOption([]string{`^/api/ignore$`, `^/api/gorm/mock`})). AddOptions(identify.FakeTokensOption([]string{})). AddOptions(identify.ModelOption(&identify.RedisModel{ Redis: addition.Redis, })). Init(func(iden *identify.Identify) { iden.AddOptions( identify.AuthOption(func(ctx *gin.Context) (interface{}, error) { login := struct { UserName string `form:"username" json:"username" xml:"username" binding:"required"` Password string `form:"password" json:"password" xml:"password" binding:"required"` Type string `form:"type" json:"type" xml:"type"` }{} if err := ctx.ShouldBind(&login); err != nil { return nil, err } user := addition.GORMExt.Var("User") if err := addition.GORMExt.DB.Find(user, map[string]interface{}{"name": login.UserName, "password": login.Password}).Error; err != nil { return nil, errors.New("user authentication failed") } return user, nil }), ) })
Identify plugin init
View Source
var Limit = &limit.Limit{ Frequency: &limit.Frequency{ Passages: []string{}, Rules: []limit.Rule{ limit.Rule{ Methods: []string{"GET"}, Match: "/api/v1/user*", Rate: 15, }, limit.Rule{ Methods: []string{"GET"}, Match: "/api/v1/role*", Rate: 5, }, }, Model: &limit.RedisModel{ Redis: addition.Redis, }, }, }
Limit Plugin init
View Source
var Logger = &logger.Logger{ Path: "logs", Format: func(p *logger.Payload, ctx *gin.Context) (f string) { if p.Type == logger.INT { startTime := time.Unix(p.StartUnix, 0).Format("2006/01/02 15:04:05") f = fmt.Sprintf("[%v bulrush] => %s %6s %s", startTime, p.IP, p.Method, p.URL) } else if p.Type == logger.OUT { endOfTime := time.Unix(p.EndUnix, 0).Format("2006/01/02 15:04:05") latency := float64(time.Unix(p.EndUnix, 0).Sub(time.Unix(p.StartUnix, 0)) / time.Millisecond) f = fmt.Sprintf("[%v bulrush] <= %.2fms %s %6s %s", endOfTime, latency, p.IP, p.Method, p.URL) } return }, }
Logger Plugin init
View Source
var MQ = mq.New()
MQ plugin init
View Source
var OpenAPI = &openapi.OpenAPI{ URLPrefix: "/gateway", Auth: func(appid string) (*openapi.AppInfo, error) { return &openapi.AppInfo{ AppID: "xxx", PublicKey: ` MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDaYoospKXldKm+/fdGh8b5Jbq4 PSrIELjHR/F6+zYExr7w0XGWC6/1Nj2Da3EWYnWo+n6URMqeyCnd09SvEmavpkUW d/4AhjZIvO42PBy9x/wFrqgU/KUqZ2r+AWFJJZgSA9IuBEqjZxsu1XTKiT7v5U7N WlboP5QLPPffz92sUwIDAQAB `, PrivateKey: ` MIICXAIBAAKBgQDaYoospKXldKm+/fdGh8b5Jbq4PSrIELjHR/F6+zYExr7w0XGW C6/1Nj2Da3EWYnWo+n6URMqeyCnd09SvEmavpkUWd/4AhjZIvO42PBy9x/wFrqgU /KUqZ2r+AWFJJZgSA9IuBEqjZxsu1XTKiT7v5U7NWlboP5QLPPffz92sUwIDAQAB AoGAAhROHH601ap2s0rXv+QrENQ7IuXyMlV2bO9SbUlXClSaHNDhs/wIgN0zWLz9 JqlpVWKNMfw1sa1WOLZ7n+8c6yq5cJLKjlHwilm0JKRUcrKY1JEln8VslIhkhBQ5 XADsNY4bevfyn4obm0/aqgXzJjLxgdMr5frlkmYaHjJhcAECQQDtC6lV4qbvphT/ JtiLiA+PS7UYpMNJLwopLofJkWwGtx+SCcEAmwEGd/DPs8jDw0xp8T6kxzs5ewHd kp4xnWyBAkEA69jk1VX4kHd3vmWVSmPZR6bPxlhGmrOunPxErwRIffiLwCCZjoUt kJPj/Lz0ZC5zCJ0+BUO3XUGH3Yrgl9Y+0wJAAiQo023ItEF7zxI6wofoHBNC/4X9 fZu/K8AP2fJGV4kv79HGvIqp57UNp9Kn7ZzGA+758eMa1doWmjnI1AnoAQJAX5wl 6HZZtfc4i+8Sfn3L78goIvhWZxDAkNOT5H+QA8FmphSRK73BowLRQfw39wT9jVhx dCDnjN6r/Zv3QJaSEQJBAK1hJlgv1pI0g2GQy/yrcb7k8QWWaKl0DgsKDVlFSjAx 9agJ0rfrBVFsjyJKlC1cpMdC/ScoqBLTIscE/12yjBg= `, }, nil }, }
OpenAPI Plugin init
View Source
var Proxy = &proxy.Proxy{ Host: "https://www.baidu.com", Match: "^/proxy", Map: func(reqPath string) string { return reqPath }, }
Proxy Plugin init
View Source
var Role = &role.Role{ RoleHandler: func(c *gin.Context, action string) bool { actions := role.TransformAction(action) addition.Logger.Debug("actions: %s\n", actions) return true }, }
Role plugin init
View Source
var Upload = upload.New()
Upload Plugin init
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.