ginutil

package module
v0.0.0-...-9850c2a Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: GPL-3.0 Imports: 19 Imported by: 15

Documentation

Index

Constants

View Source
const DebugMode = gin.DebugMode
View Source
const ReleaseMode = gin.ReleaseMode
View Source
const TestMode = gin.TestMode

Variables

View Source
var Default = gin.Default
View Source
var SetMode = gin.SetMode

Functions

func CallAfterFunc

func CallAfterFunc(urlStr string, ctx Context, params ...interface{}) *emity.MsgEmity

*

  • 调用Aop-函数执行后调用函数
  • @param urlStr 被监听控制Url地址(注册web接口时的url地址)
  • @param doFunc 被调用函数
  • @return

func CallAroundFunc

func CallAroundFunc(urlStr string, ctx Context, params ...interface{}) *emity.MsgEmity

*

  • 调用Aop-函数执行中调用函数
  • @param urlStr 被监听控制Url地址(注册web接口时的url地址)
  • @param doFunc 被调用函数
  • @return

func CallBeforeFunc

func CallBeforeFunc(urlStr string, ctx Context, params ...interface{}) *emity.MsgEmity

*

  • 调用Aop-控制函数执行前调用函数
  • @param urlStr 被监听控制Url地址(注册web接口时的url地址)
  • @param doFunc 被调用函数
  • @return

func CallFuncByUrl

func CallFuncByUrl(url string, iType RequestType, ctx Context) interface{}

*

  • 根据url取函数
  • @param url
  • @param iType
  • @param ctx
  • @return

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 GetHandleWebsocketFunc

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

*

  • 取注册的Websocket接口

func RegisterAfter

func RegisterAfter(urlStr string, doFunc func(ctx Context, params ...interface{}) *emity.MsgEmity)

*

  • 注册Aop-控制函数执行后调用函数
  • @param urlStr 被监听控制Url地址(注册web接口时的url地址)
  • @param doFunc 被调用函数
  • @return

func RegisterAround

func RegisterAround(urlStr string, doFunc func(ctx Context, params ...interface{}) *emity.MsgEmity)

*

  • 注册Aop-控制函数执行中调用函数
  • @param urlStr 被监听控制Url地址(注册web接口时的url地址)
  • @param doFunc 被调用函数
  • @return

func RegisterBefore

func RegisterBefore(urlStr string, doFunc func(ctx Context, params ...interface{}) *emity.MsgEmity)

*

  • 注册Aop-函数执行前调用函数
  • @param urlStr 被监听函数
  • @param doFunc 被调用函数
  • @return

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)

关闭服务

func WebsocketServe

func WebsocketServe(context Context)

*

  • websocket服务
  • @param 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"
	WEBSOCKET RequestType = "WEBSOCKET"
)

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