Web

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTP_STATUS = "GOFT_STATUS"
)

Gin 错误中间件

Variables

This section is empty.

Functions

func Convert

func Convert(handler interface{}) gin.HandlerFunc

func Error

func Error(err error, msg ...string)

func ErrorHandler

func ErrorHandler() gin.HandlerFunc

func HandleFairing

func HandleFairing(responder Responder, ctx *gin.Context) interface{}

Deprecated ,please call FairingHandler.handlerFairing

func Throw

func Throw(err string, code int, context *gin.Context)

Types

type Fairing

type Fairing interface {
	OnRequest(*gin.Context) error
	OnResponse(result interface{}) (interface{}, error)
}

中间件 接口

type FairingHandler

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

func NewFairingHandler

func NewFairingHandler() *FairingHandler

func (*FairingHandler) AddFairing

func (this *FairingHandler) AddFairing(f ...Fairing)

type Goft

type Goft struct {
	*gin.Engine
	// contains filtered or unexported fields
}

func New

func New() *Goft

func (*Goft) Attach

func (this *Goft) Attach(f ...Fairing) *Goft

注册中间件

func (*Goft) Handle

func (this *Goft) Handle(httpMethod, relativePath string, handler interface{}) *Goft

func (*Goft) HandleWithFairing

func (this *Goft) HandleWithFairing(httpMethod, relativePath string, handler interface{}, fairings ...Fairing) *Goft

func (*Goft) Launch

func (this *Goft) Launch(port int32)

func (*Goft) Mount

func (this *Goft) Mount(group string, classes ...IClass) *Goft

type GoftTree

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

func NewGoftTree

func NewGoftTree() *GoftTree

type IClass

type IClass interface {
	Build(goft *Goft) //参数和方法名必须一致
	Name() string
}

type Json

type Json interface{}

type JsonResponder

type JsonResponder func(*gin.Context) Json

func (JsonResponder) RespondTo

func (this JsonResponder) RespondTo() gin.HandlerFunc

type Model

type Model interface {
	String() string
}

模型

type Models

type Models string

func MakeModels

func MakeModels(v interface{}) Models

type Param

type Param struct {
	Key   string
	Value string
}

Param is a single URL parameter, consisting of a key and a value.

type Params

type Params []Param

Params is a Param-slice, as returned by the router. The slice is ordered, the first URL parameter is also the first slice value. It is therefore safe to read values by the index.

func (Params) ByName

func (ps Params) ByName(name string) (va string)

ByName returns the value of the first Param which key matches the given name. If no matching Param is found, an empty string is returned.

func (Params) Get

func (ps Params) Get(name string) (string, bool)

Get returns the value of the first Param which key matches the given name. If no matching Param is found, an empty string is returned.

type Responder

type Responder interface {
	RespondTo() gin.HandlerFunc
}

type RouteInfo

type RouteInfo struct {
	Method      string
	Path        string
	Handler     string
	HandlerFunc interface{}
}

路由树解析

type RoutesInfo

type RoutesInfo []RouteInfo

type SqlQueryResponder

type SqlQueryResponder func(*gin.Context) Sql.Query

func (SqlQueryResponder) RespondTo

func (this SqlQueryResponder) RespondTo() gin.HandlerFunc

type SqlResponder

type SqlResponder func(*gin.Context) Sql.SimpleQuery

func (SqlResponder) RespondTo

func (this SqlResponder) RespondTo() gin.HandlerFunc

type StringResponder

type StringResponder func(*gin.Context) string

func (StringResponder) RespondTo

func (this StringResponder) RespondTo() gin.HandlerFunc

type TreeNode

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

解析路由

type TreeRouter

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

func NewTreeRouter

func NewTreeRouter() *TreeRouter

type View deprecated

type View string

Deprecated: 暂时不提供View的解析

type ViewResponder

type ViewResponder func(*gin.Context) View

func (ViewResponder) RespondTo

func (this ViewResponder) RespondTo() gin.HandlerFunc

Jump to

Keyboard shortcuts

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