|
@@ -9,6 +9,7 @@ import (
|
|
"bytes"
|
|
"bytes"
|
|
"context"
|
|
"context"
|
|
"fmt"
|
|
"fmt"
|
|
|
|
+ "github.com/zeromicro/go-zero/core/service"
|
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
|
"github.com/zeromicro/go-zero/core/validation"
|
|
"github.com/zeromicro/go-zero/core/validation"
|
|
"github.com/zeromicro/go-zero/rest/httpx"
|
|
"github.com/zeromicro/go-zero/rest/httpx"
|
|
@@ -34,6 +35,7 @@ var (
|
|
appSecrets = make(map[string]secretExpire)
|
|
appSecrets = make(map[string]secretExpire)
|
|
appSecretsLock sync.Mutex
|
|
appSecretsLock sync.Mutex
|
|
validator atomic.Value
|
|
validator atomic.Value
|
|
|
|
+ confMode string
|
|
)
|
|
)
|
|
|
|
|
|
type (
|
|
type (
|
|
@@ -57,6 +59,7 @@ type (
|
|
)
|
|
)
|
|
|
|
|
|
func NewDataSignMiddleware(conf config.Config) *DataSignMiddleware {
|
|
func NewDataSignMiddleware(conf config.Config) *DataSignMiddleware {
|
|
|
|
+ confMode = conf.Mode
|
|
mysql := sqlx.NewMysql(conf.DtDataStoreDB.DataSource)
|
|
mysql := sqlx.NewMysql(conf.DtDataStoreDB.DataSource)
|
|
return &DataSignMiddleware{
|
|
return &DataSignMiddleware{
|
|
AppInfo: model.NewDcAppInfoModel(mysql),
|
|
AppInfo: model.NewDcAppInfoModel(mysql),
|
|
@@ -64,6 +67,11 @@ func NewDataSignMiddleware(conf config.Config) *DataSignMiddleware {
|
|
}
|
|
}
|
|
|
|
|
|
func (m *DataSignMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
|
|
func (m *DataSignMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
|
|
|
|
+ if confMode == service.DevMode {
|
|
|
|
+ return func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
+ next(w, r)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
cps := CommonParams{}
|
|
cps := CommonParams{}
|
|
err := m.parseCommonParams(r, &cps)
|
|
err := m.parseCommonParams(r, &cps)
|