From d4a73b93d3213bf6a2b2fc9b18d578cfc4d25cee Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Mon, 27 Sep 2021 09:52:27 +0800 Subject: [PATCH] awd --- conf/wheat-cache.yaml | 2 +- middleware/config/middle_conf.go | 14 ++++++++++++++ middleware/define.go | 2 +- middleware/log-middle/middleware.go | 22 ++++++++++++++++++++++ pkg/middle/define.go | 6 ++++++ 5 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 middleware/config/middle_conf.go create mode 100644 middleware/log-middle/middleware.go diff --git a/conf/wheat-cache.yaml b/conf/wheat-cache.yaml index 4475627..1b51a1d 100644 --- a/conf/wheat-cache.yaml +++ b/conf/wheat-cache.yaml @@ -5,4 +5,4 @@ env: 'dev' storage: host: '127.0.0.1' port: 5890 - + diff --git a/middleware/config/middle_conf.go b/middleware/config/middle_conf.go new file mode 100644 index 0000000..3d78198 --- /dev/null +++ b/middleware/config/middle_conf.go @@ -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, + } +} diff --git a/middleware/define.go b/middleware/define.go index c93eb35..c116927 100644 --- a/middleware/define.go +++ b/middleware/define.go @@ -2,5 +2,5 @@ package middleware type MiddlewareInterface interface { Init() - Exet(interface{}) (interface{}, error) + Exat(interface{}) (interface{}, error) } diff --git a/middleware/log-middle/middleware.go b/middleware/log-middle/middleware.go new file mode 100644 index 0000000..a2d4cd0 --- /dev/null +++ b/middleware/log-middle/middleware.go @@ -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{} +} diff --git a/pkg/middle/define.go b/pkg/middle/define.go index 94eaada..1fc688a 100644 --- a/pkg/middle/define.go +++ b/pkg/middle/define.go @@ -1 +1,7 @@ package middle + +import middleConf "gitee.com/timedb/wheatCache/middleware/config" + +func init() { + middleConf.GetMiddlewareMap() +}