!35 方案分支

Merge pull request !35 from bandl/fd-middle-tools
This commit is contained in:
bandl 2021-09-28 14:58:15 +00:00 committed by Gitee
commit 0903477c22
5 changed files with 44 additions and 2 deletions

View File

@ -5,4 +5,4 @@ env: 'dev'
storage:
host: '127.0.0.1'
port: 5890

View File

@ -0,0 +1,14 @@
package config
import (
"gitee.com/timedb/wheatCache/middleware"
logMiddle "gitee.com/timedb/wheatCache/middleware/log-middle"
)
func GetMiddlewareMap() map[string]middleware.MiddlewareInterface {
logMiddlewareCase := logMiddle.NewMiddleware()
return map[string]middleware.MiddlewareInterface{
"logMiddlewareCase": logMiddlewareCase,
}
}

View File

@ -2,5 +2,5 @@ package middleware
type MiddlewareInterface interface {
Init()
Exet(interface{}) (interface{}, error)
Exat(interface{}) (interface{}, error)
}

View File

@ -0,0 +1,22 @@
package log_middle
import (
"fmt"
"gitee.com/timedb/wheatCache/middleware"
)
type A struct {
}
func (i *A) Init() {
}
func (i *A) Exat(interface{}) (interface{}, error) {
fmt.Println(1)
return nil, nil
}
func NewMiddleware() middleware.MiddlewareInterface {
return &A{}
}

View File

@ -1 +1,7 @@
package middle
import middleConf "gitee.com/timedb/wheatCache/middleware/config"
func init() {
middleConf.GetMiddlewareMap()
}