ggin

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package ggin Created by guoxin in 2020/10/25 5:58 下午

Package ggin Created by guoxin in 2020/11/1 4:08 下午

Package ggin Create by guoxin 2021.07.02

Package ggin Create by guoxin 2021.07.02

Package ggin Created by guoxin in 2020/10/31 10:01 下午

Package ggin Created by guoxin in 2020/10/31 10:01 下午

Package ggin Created by guoxin in 2020/10/31 10:01 下午

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ginzap

func Ginzap(logger *zap.Logger, timeFormat string, utc bool) gin.HandlerFunc

Ginzap returns a gin.HandlerFunc (middleware) that logs requests using uber-go/zap.

Requests with errors are logged using zap.Error(). Requests without errors are logged using zap.Info().

It receives:

  1. A time package format string (e.g. time.RFC3339).
  2. A boolean stating whether to use UTC time zone or local.

func HandlerNotFound

func HandlerNotFound(c *gin.Context)

func New

func New(params ...interface{})

func RecoveryWithZap

func RecoveryWithZap(logger *zap.Logger, stack bool) gin.HandlerFunc

RecoveryWithZap returns a gin.HandlerFunc (middleware) that recovers from any panics and logs requests using uber-go/zap. All errors are logged using zap.Error(). stack means whether output the stack info. The stack info is easy to find where the error occurs but the stack info is too large.

Types

type Configuration

type Configuration struct {
	// Make sure you only initialize it once
	core.InitializeLock
	Port string
	// contains filtered or unexported fields
}

func (*Configuration) Initialize

func (c *Configuration) Initialize(params ...interface{}) interface{}

Initialize https://www.cnblogs.com/kainhuck/p/13333765.html

type Controller

type Controller func(p *Parameter) *Result

Controller Implement Controller coding the interface

type ControllerConfiguration

type ControllerConfiguration interface {
	Configure(Controllers)
}

ControllerConfiguration Register the Controller with the gin.RouterGroup route

type Controllers

type Controllers struct {
	*gin.Engine
}

Controllers Here can use gin.Engine and gin.RouterGroup. gin.RouterGroup.Group() No good ideas yet Controllers are c *gin.Engine wrappers

func (*Controllers) CONNECT

func (c *Controllers) CONNECT(path string, controller Controller)

func (*Controllers) DELETE

func (c *Controllers) DELETE(path string, controller Controller)

func (*Controllers) GET

func (c *Controllers) GET(path string, controller Controller)

func (*Controllers) HEAD

func (c *Controllers) HEAD(path string, controller Controller)

func (*Controllers) OPTIONS

func (c *Controllers) OPTIONS(path string, controller Controller)

func (*Controllers) PATCH

func (c *Controllers) PATCH(path string, controller Controller)

func (*Controllers) POST

func (c *Controllers) POST(path string, controller Controller)

func (*Controllers) PUT

func (c *Controllers) PUT(path string, controller Controller)

func (*Controllers) Register

func (c *Controllers) Register(method string, path string, controller Controller)

func (*Controllers) TRACE

func (c *Controllers) TRACE(path string, controller Controller)

type Parameter

type Parameter struct {
	*gin.Context
}

type Result

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

Result Http result

type ResultBuilder

type ResultBuilder interface {
}

ResultBuilder request

  1. query
  2. body
  3. path
  4. header

response

  1. code
  2. body

type ResultMessage

type ResultMessage struct {
	Code    int    `json:"code"`
	Message string `json:"msg"`
}

ResultMessage 响应码对象

Jump to

Keyboard shortcuts

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