ginutil

package module
v0.0.0-...-011e279 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 License: GPL-3.0 Imports: 16 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ControllerRegister

func ControllerRegister(url string, handler func(ctx Context) interface{}, iTypes ...RequestType)

注册web接口

func Cors

func Cors() gin.HandlerFunc

跨域函数

func GetController

func GetController() map[string]HttpHandleInfo

取注册的web接口

func GetGin

func GetGin(ginMode, webRoot, Port string, InterceptorFunc func(ctx Context) bool) *http.Server

func GetHandleFunc

func GetHandleFunc(urlKey string, iType RequestType, InterceptorFunc func(ctx Context) bool,
	controllerMap map[string]HttpHandleInfo) func(ctx Context)

*

  • 取注册的web接口

func RegisterController

func RegisterController(url string, iTypes interface{}, handler func(ctx Context) interface{})

注册web接口

func RegisterControllers

func RegisterControllers(url string, iTypes interface{}, handler func(ctx Context) interface{})

注册web接口

func SetCors

func SetCors(r *gin.Engine)

设置跨域

func SetStatic

func SetStatic(r *gin.Engine, webroot string)

设置静态路径

func Shutdown

func Shutdown(ctx Context)

关闭服务

Types

type Context

type Context = *gin.Context

type HttpHandleInfo

type HttpHandleInfo struct {
	Url  string
	Type RequestType
	Fun  func(ctx Context) interface{}
}

http控制层接口信息

type RequestType

type RequestType string

请求类型枚举

const (
	GET     RequestType = "GET"
	POST    RequestType = "POST"
	DELETE  RequestType = "DELETE"
	PUT     RequestType = "PUT"
	OPTIONS RequestType = "OPTIONS"
)

func (RequestType) String

func (rt RequestType) String() string

枚举转字符串

Jump to

Keyboard shortcuts

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