forked from p93542168/wheat-cache
!41 fix-middle-tools
Merge pull request !41 from bandl/fix-middle-tools
This commit is contained in:
commit
5888e2e15a
2
makefile
2
makefile
|
@ -13,6 +13,7 @@ build:
|
||||||
|
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
install:
|
install:
|
||||||
|
@make gen-middleware
|
||||||
@make build
|
@make build
|
||||||
|
|
||||||
.PHONY: dev
|
.PHONY: dev
|
||||||
|
@ -27,5 +28,6 @@ gen-struct:
|
||||||
gen-protobuf:
|
gen-protobuf:
|
||||||
@python3 ./shell/gen_protobuf.py
|
@python3 ./shell/gen_protobuf.py
|
||||||
|
|
||||||
|
.PHONY: gen-middleware
|
||||||
gen-middleware:
|
gen-middleware:
|
||||||
@python3 ./shell/gen_middleware.py
|
@python3 ./shell/gen_middleware.py
|
||||||
|
|
|
@ -6,16 +6,15 @@ package config
|
||||||
import (
|
import (
|
||||||
"gitee.com/timedb/wheatCache/middleware"
|
"gitee.com/timedb/wheatCache/middleware"
|
||||||
|
|
||||||
logMiddle "gitee.com/timedb/wheatCache/middleware/log-middle"
|
logMiddle "gitee.com/timedb/wheatCache/middleware/log-middle"
|
||||||
mapKey "gitee.com/timedb/wheatCache/middleware/map-key"
|
mapKey "gitee.com/timedb/wheatCache/middleware/map-key"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func GetMiddlewareMap() map[string]middleware.MiddleToolsInterface {
|
||||||
|
|
||||||
func GetMiddlewareMap() map[string]middleware.MiddlewareInterface {
|
return map[string]middleware.MiddleToolsInterface{
|
||||||
|
|
||||||
return map[string]middleware.MiddlewareInterface{
|
"logMiddle": logMiddle.NewMiddleware(),
|
||||||
|
"mapKey": mapKey.NewMiddleware(),
|
||||||
"logMiddle":logMiddle.NewMiddleware(),
|
|
||||||
"mapKey":mapKey.NewMiddleware(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,9 +11,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func GetMiddlewareMap() map[string]middleware.MiddlewareInterface {
|
func GetMiddlewareMap() map[string]middleware.MiddleToolsInterface {
|
||||||
|
|
||||||
return map[string]middleware.MiddlewareInterface{
|
return map[string]middleware.MiddleToolsInterface{
|
||||||
{%for dir in dirs %}
|
{%for dir in dirs %}
|
||||||
"{{dir[0]}}":{{dir[0]}}.NewMiddleware(),
|
"{{dir[0]}}":{{dir[0]}}.NewMiddleware(),
|
||||||
{%- endfor%}
|
{%- endfor%}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package middleware
|
package middleware
|
||||||
|
|
||||||
type MiddlewareInterface interface {
|
type MiddleToolsInterface interface {
|
||||||
Init()
|
Init()
|
||||||
Exat(interface{}) (interface{}, error)
|
Exec(interface{}) (interface{}, error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,11 @@ type A struct {
|
||||||
func (i *A) Init() {
|
func (i *A) Init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *A) Exat(interface{}) (interface{}, error) {
|
func (i *A) Exec(interface{}) (interface{}, error) {
|
||||||
fmt.Println(1)
|
fmt.Println(1)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMiddleware() middleware.MiddlewareInterface {
|
func NewMiddleware() middleware.MiddleToolsInterface {
|
||||||
return &A{}
|
return &A{}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,11 @@ type ABB struct {
|
||||||
func (i *ABB) Init() {
|
func (i *ABB) Init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *ABB) Exat(interface{}) (interface{}, error) {
|
func (i *ABB) Exec(interface{}) (interface{}, error) {
|
||||||
fmt.Println(1)
|
fmt.Println(1)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMiddleware() middleware.MiddlewareInterface {
|
func NewMiddleware() middleware.MiddleToolsInterface {
|
||||||
return &ABB{}
|
return &ABB{}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue