types

package
v0.0.0-...-525798f Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultApp = &App{
		Name: "demo",
		Mode: consts.DevMode,
		Version: &Version{
			Latest: "1.0.0",
			Key:    "app_version",
		},
		Session: &Session{
			Key:        "sess_token",
			KeyPrefix:  "ci_session:",
			Expiration: 6 * 30 * 86400,
		},
		Logger: &Logger{
			Dir:         "apps/logs/go/demo",
			LogTimeout:  3 * time.Second,
			SendTimeout: 5 * time.Second,
		},
		Sign: &Sign{
			SecretKey:  "1234!@#$",
			Key:        "sess_token",
			TimeKey:    "utime",
			Dev:        "bgin-dev-sign",
			Expiration: 60,
		},
		Server: &Server{
			Addr:            "0.0.0.0:9999",
			ReadTimeout:     10 * time.Second,
			WriteTimeout:    15 * time.Second,
			ShutDownTimeout: 15 * time.Second,
		},
	}
)

Functions

This section is empty.

Types

type App

type App struct {
	Name    string
	Mode    string
	Version *Version
	Logger  *Logger
	Server  *Server
	Sign    *Sign
	Session *Session
}

func (*App) GetSession

func (a *App) GetSession() (clientFunc func() *redis.Client, key, prefix string, expiration int64)

func (*App) GetSign

func (a *App) GetSign() (secretKey, key, timeKey, dev string, expiration int64)

func (*App) GetVersion

func (a *App) GetVersion() (version, key string)

func (*App) Run

func (a *App) Run(options ...func(app *App))

func (*App) SetMode

func (a *App) SetMode(mode string) *App

type Controller

type Controller struct {
	Ctx *gin.Context
}

func (*Controller) DumpRequest

func (c *Controller) DumpRequest() string

func (*Controller) GetLoggedUserId

func (c *Controller) GetLoggedUserId() int

GetLoggedUserId 获取已登陆用户的ID

func (*Controller) GetQueryByMethod

func (c *Controller) GetQueryByMethod(key, defaultValue string) string

GetQueryByMethod 根据ctx.httpMethod获取GET或POST参数

func (*Controller) GetQueryPostForm

func (c *Controller) GetQueryPostForm(keys ...string) string

从Get和Post里获取Key的值

func (*Controller) Json

func (c *Controller) Json(args ...interface{})

Json 输出方法 args 三个参数: 第一个是code,第二个是msg,第三个是data

func (*Controller) PostForm

func (c *Controller) PostForm(keys ...string) string

PostForm 从Post里获取Key的值

func (*Controller) Query

func (c *Controller) Query(keys ...string) string

Query 从Get里获取Key的值

func (*Controller) QueryPostNumber

func (c *Controller) QueryPostNumber(key string, defaultValue ...int) int

QueryPostNumber 从Query或PostForm中获取数字类型key值

func (*Controller) SetContext

func (c *Controller) SetContext(ctx *gin.Context)

type ICheck

type ICheck interface {
	GetVersion() (version, key string)
	GetSign() (secretKey, key, timeKey, dev string, expiration int64)
	GetSession() (fn func() *redis.Client, key, prefix string, expiration int64)
}

type IController

type IController interface {
	SetContext(*gin.Context)
}

type Logger

type Logger struct {
	Dir         string
	LogTimeout  time.Duration
	SendTimeout time.Duration
}

type Model

type Model struct {
	mysql.Model
}

func (*Model) Config

func (m *Model) Config(db string, options ...interface{}) func() *gorm.Config

type Redis

type Redis struct {
	redis.Redis
}

type RestHandler

type RestHandler struct {
	Sort    int             // Sort
	Signed  bool            // Signed
	Logged  bool            // Logged
	Path    string          // Path
	Version string          // Version
	Http    string          // Http
	Method  string          // Method
	Handler IController     // Handler
	Https   map[string]byte // Https
}

func (*RestHandler) CallMethod

func (h *RestHandler) CallMethod(ctx *gin.Context)

func (*RestHandler) GetHttps

func (h *RestHandler) GetHttps() map[string]byte

type RestHandlers

type RestHandlers []RestHandler

func (RestHandlers) Len

func (rh RestHandlers) Len() int

func (RestHandlers) Less

func (rh RestHandlers) Less(i, j int) bool

func (RestHandlers) Swap

func (rh RestHandlers) Swap(i, j int)

type Restful

type Restful map[string]RestHandlers

type Sender

type Sender struct {
	// contains filtered or unexported fields
}

func (*Sender) Always

func (s *Sender) Always() bool

func (*Sender) Open

func (s *Sender) Open() bool

func (*Sender) Push

func (s *Sender) Push(msg string)

type Server

type Server struct {
	Addr            string
	ReadTimeout     time.Duration
	WriteTimeout    time.Duration
	ShutDownTimeout time.Duration
	Http            *http.Server
}

type Session

type Session struct {
	Key        string
	KeyPrefix  string
	Expiration int64
	ClientFunc func() *redis.Client
}

type Sign

type Sign struct {
	SecretKey  string
	Key        string
	TimeKey    string
	Dev        string
	Expiration int64
}

type Version

type Version struct {
	Latest, Key string
}

Jump to

Keyboard shortcuts

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