mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-21 10:13:01 +00:00
refactor🎨 优化Context设置方法
This commit is contained in:
+3
-9
@@ -18,7 +18,8 @@ type Api struct {
|
||||
Logger *logger.Logger
|
||||
}
|
||||
|
||||
func (e Api) SetContext(c *gin.Context) {
|
||||
// MakeContext 设置http上下文
|
||||
func (e *Api) MakeContext(c *gin.Context) {
|
||||
fmt.Println(&c)
|
||||
e.Context = c
|
||||
fmt.Println(&e.Context)
|
||||
@@ -30,13 +31,6 @@ func (e Api) GetLogger() *logger.Logger {
|
||||
return api.GetRequestLogger(e.Context)
|
||||
}
|
||||
|
||||
//func (e Api) GetLogger() (*logger.Logger, error) {
|
||||
// if e.Context == nil {
|
||||
// return nil, errors.New("API context cannot be nil")
|
||||
// }
|
||||
// return api.GetRequestLogger(e.Context), nil
|
||||
//}
|
||||
|
||||
func (e Api) Bind(d interface{}, bindings ...binding.Binding) error {
|
||||
var err error
|
||||
for i := range bindings {
|
||||
@@ -99,4 +93,4 @@ func (e Api) PageOK(result interface{}, count int, pageIndex int, pageSize int,
|
||||
// Custom 兼容函数
|
||||
func (e Api) Custom(data gin.H) {
|
||||
response.Custum(e.Context, data)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user