ginger

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

README

ginger

Package of gin framework

使用到的包与组件

1.gin

github.com/gin-gonic/gin

2.gzip压缩

https://github.com/gin-contrib/gzip

3.swagger

github.com/swaggo/gin-swagger

Wish list

1.gzip yes

2.上传,图像裁剪,真实URL屏蔽 no

3.gin常用功能封装 yes

4.gin命令行工具 yes

5.数据库工具(数据库迁移,数据库填充,数据库默认创建,自动字段生成) no

6.日志处理 ES,FILE支持 no

7.swagger集成 yes

8.socket和ws协议集成 no

9.grpc支持 no

10.test单元测试,基准测试快速创建工具 no

Documentation

Index

Constants

View Source
const (
	CliString = iota
	CliBool
	CliInt
)
View Source
const (
	ExplainMain = iota
	ExplainItem
)
View Source
const (
	BestCompression    = gzip.BestCompression
	BestSpeed          = gzip.BestSpeed
	DefaultCompression = gzip.DefaultCompression
	NoCompression      = gzip.NoCompression
)

Variables

View Source
var (
	DefaultExcludedExtensions = NewExcludedExtensions([]string{
		".png", ".gif", ".jpeg", ".jpg",
	})
	DefaultOptions = &Options{
		ExcludedExtensions: DefaultExcludedExtensions,
	}
)

Functions

func Cors

func Cors() gin.HandlerFunc

func DefaultDecompressHandle

func DefaultDecompressHandle(c *gin.Context)

func Gzip

func Gzip(level int, options ...Option) gin.HandlerFunc

Types

type Cli added in v0.0.4

type Cli struct {
	Row        CliRow
	ExplainRow Explain
	Explains   []Explain
}
var CliIns *Cli

func GetCli added in v0.0.4

func GetCli() *Cli

单例模式获取实例

func (*Cli) Explain added in v0.0.4

func (c *Cli) Explain(info string) *Cli

func (*Cli) Item added in v0.0.4

func (c *Cli) Item(name string) *Cli

func (*Cli) Save added in v0.0.4

func (c *Cli) Save() CliInput

func (*Cli) SaveExplain added in v0.0.4

func (c *Cli) SaveExplain() bool

解析CLI命令并返回是否有说明

func (*Cli) SetBoolDefault added in v0.0.4

func (c *Cli) SetBoolDefault(d interface{}) *Cli

func (*Cli) SetDefault added in v0.0.4

func (c *Cli) SetDefault(d interface{}) *Cli

func (*Cli) SetExplainItem added in v0.0.4

func (c *Cli) SetExplainItem(info string) *Cli

func (*Cli) SetIntDefault added in v0.0.4

func (c *Cli) SetIntDefault(d interface{}) *Cli

func (*Cli) SetUsage added in v0.0.4

func (c *Cli) SetUsage(usage string) *Cli

type CliData added in v0.0.4

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

func (*CliData) GetBool added in v0.0.4

func (c *CliData) GetBool() bool

func (*CliData) GetInt added in v0.0.4

func (c *CliData) GetInt() int

func (*CliData) GetString added in v0.0.4

func (c *CliData) GetString() string

type CliInput added in v0.0.4

type CliInput interface {
	GetInt() int
	GetString() string
	GetBool() bool
}

type CliRow added in v0.0.4

type CliRow struct {
	Name    string
	Type    int
	Default interface{}
	UseAge  string
}

type ExcludedExtensions

type ExcludedExtensions map[string]bool

Using map for better lookup performance

func NewExcludedExtensions

func NewExcludedExtensions(extensions []string) ExcludedExtensions

func (ExcludedExtensions) Contains

func (e ExcludedExtensions) Contains(target string) bool

type ExcludedPaths

type ExcludedPaths []string

func NewExcludedPaths

func NewExcludedPaths(paths []string) ExcludedPaths

func (ExcludedPaths) Contains

func (e ExcludedPaths) Contains(requestURI string) bool

type Explain added in v0.0.4

type Explain struct {
	Info string
	Type int
}

type GRPCContainer added in v0.0.6

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

func (*GRPCContainer) New added in v0.0.6

func (g *GRPCContainer) New(addr string) *GRPCContainer

func (*GRPCContainer) Register added in v0.0.6

func (g *GRPCContainer) Register(server *interface{})

type Ginger

type Ginger struct {
	App *gin.Engine
	// contains filtered or unexported fields
}
var IGinger *Ginger

func GetIns

func GetIns() *Ginger

单例模式获取实例

func (*Ginger) Debug

func (g *Ginger) Debug(isDebug bool) *Ginger

默认就是DEBUG。如果设置为FALSE,则ReleaseMode

func (*Ginger) GetHTTPServeMux added in v0.0.6

func (g *Ginger) GetHTTPServeMux() *http.ServeMux

func (*Ginger) LoadRouter

func (g *Ginger) LoadRouter(router func(router *gin.Engine) gin.IRoutes) *Ginger

加载路由

func (*Ginger) Run added in v0.0.6

func (g *Ginger) Run(addr string, f ...func(server *grpc.Server)) (err error)

func (*Ginger) Start

func (g *Ginger) Start(addr string)

开启服务

func (*Ginger) Swagger added in v0.0.4

func (g *Ginger) Swagger(openSwagger bool) *Ginger

开启swagger

type Option

type Option func(*Options)

func WithDecompressFn

func WithDecompressFn(decompressFn func(c *gin.Context)) Option

func WithExcludedExtensions

func WithExcludedExtensions(args []string) Option

func WithExcludedPaths

func WithExcludedPaths(args []string) Option

type Options

type Options struct {
	ExcludedExtensions ExcludedExtensions
	ExcludedPaths      ExcludedPaths
	DecompressFn       func(c *gin.Context)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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