github.com/SupenBysz/gf-admin-community@v0.7.4/sys_service/sys_middleware.go (about)

     1  // ================================================================================
     2  // Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
     3  // You can delete these comments if you wish manually maintain this interface file.
     4  // ================================================================================
     5  
     6  package sys_service
     7  
     8  import (
     9  	"github.com/gogf/gf/v2/net/ghttp"
    10  )
    11  
    12  type (
    13  	IMiddleware interface {
    14  		// Auth 通讯鉴权
    15  		Auth(r *ghttp.Request)
    16  		// CTX 自定义上下文对象
    17  		CTX(r *ghttp.Request)
    18  		// CORS 允许接口跨域请求
    19  		CORS(r *ghttp.Request)
    20  		// ResponseHandler 响应函数
    21  		ResponseHandler(r *ghttp.Request)
    22  	}
    23  )
    24  
    25  var (
    26  	localMiddleware IMiddleware
    27  )
    28  
    29  func Middleware() IMiddleware {
    30  	if localMiddleware == nil {
    31  		panic("implement not found for interface IMiddleware, forgot register?")
    32  	}
    33  	return localMiddleware
    34  }
    35  
    36  func RegisterMiddleware(i IMiddleware) {
    37  	localMiddleware = i
    38  }