环境变量枚举小写

master
hzy 1 year ago
parent dbf807b047
commit 523d75fa30
  1. 34
      enum/env.pb.go
  2. 4
      glog/v1/logger.go
  3. 2
      interceptor/v1/grpc/interceptor.go
  4. 2
      transport/v1/http/request.go
  5. 6
      transport/v1/http/response.go

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc v3.19.4
// protoc v4.22.4
// source: enum/env.proto
package enum
@ -23,25 +23,25 @@ const (
type Env int32
const (
Env_Local Env = 0
Env_Develop Env = 1
Env_Preview Env = 2
Env_Production Env = 3
Env_local Env = 0
Env_develop Env = 1
Env_preview Env = 2
Env_production Env = 3
)
// Enum value maps for Env.
var (
Env_name = map[int32]string{
0: "Local",
1: "Develop",
2: "Preview",
3: "Production",
0: "local",
1: "develop",
2: "preview",
3: "production",
}
Env_value = map[string]int32{
"Local": 0,
"Develop": 1,
"Preview": 2,
"Production": 3,
"local": 0,
"develop": 1,
"preview": 2,
"production": 3,
}
)
@ -77,10 +77,10 @@ var File_enum_env_proto protoreflect.FileDescriptor
var file_enum_env_proto_rawDesc = []byte{
0x0a, 0x0e, 0x65, 0x6e, 0x75, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x12, 0x10, 0x70, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x78, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x65, 0x6e,
0x75, 0x6d, 0x2a, 0x3a, 0x0a, 0x03, 0x45, 0x6e, 0x76, 0x12, 0x09, 0x0a, 0x05, 0x4c, 0x6f, 0x63,
0x61, 0x6c, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x10,
0x01, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x10, 0x02, 0x12, 0x0e,
0x0a, 0x0a, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x03, 0x42, 0x30,
0x75, 0x6d, 0x2a, 0x3a, 0x0a, 0x03, 0x45, 0x6e, 0x76, 0x12, 0x09, 0x0a, 0x05, 0x6c, 0x6f, 0x63,
0x61, 0x6c, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x10,
0x01, 0x12, 0x0b, 0x0a, 0x07, 0x70, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x10, 0x02, 0x12, 0x0e,
0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x03, 0x42, 0x30,
0x5a, 0x2e, 0x67, 0x69, 0x74, 0x65, 0x61, 0x2e, 0x64, 0x72, 0x75, 0x67, 0x65, 0x79, 0x65, 0x73,
0x2e, 0x76, 0x69, 0x70, 0x2f, 0x70, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x78, 0x62, 0x61, 0x73, 0x65,
0x2f, 0x75, 0x74, 0x69, 0x6c, 0x73, 0x2f, 0x65, 0x6e, 0x75, 0x6d, 0x3b, 0x65, 0x6e, 0x75, 0x6d,

@ -35,9 +35,9 @@ func NewLogger(c *LoggerConfig) (log.Logger, func()) {
switch c.Env {
default:
l = NewStdLogger(os.Stdout)
case enum.Env_Local.String():
case enum.Env_local.String():
l = NewStdLogger(os.Stdout)
case enum.Env_Develop.String(), enum.Env_Preview.String(), enum.Env_Production.String():
case enum.Env_develop.String(), enum.Env_preview.String(), enum.Env_production.String():
l = NewAliyunLog(
WithAccessKey(c.AliLogConfig.AccessKey),
WithAccessSecret(c.AliLogConfig.AccessSecret),

@ -42,7 +42,7 @@ func (i *Interceptor) UnaryServerInterceptor() grpc.UnaryServerInterceptor {
return
}
if i.env == enum.Env_Production {
if i.env == enum.Env_production {
se := errors.FromError(err)
if _, ok := i.reason[se.Reason]; ok {
// 业务错误,原样返回

@ -125,7 +125,7 @@ func (t *Transport) RequestDecoderWithSignFilter(noEncrypt map[string]bool) http
}
// 正式服验签
if t.env == enum.Env_Production && !noEncrypt[r.URL.Path] {
if t.env == enum.Env_production && !noEncrypt[r.URL.Path] {
signature := request.NewSignature(t.apiKey, request.NewSHA1HashAlg())
signStr := signature.GenSignature(params)
if signStr != r.Header.Get("sm5") {

@ -104,7 +104,7 @@ func (t *Transport) ResponseEncoderWithEncrypt() http.EncodeResponseFunc {
dataRes := string(data)
// 正式服加密
if t.env == enum.Env_Production {
if t.env == enum.Env_production {
ecbMsg, err := sm4.Sm4Ecb([]byte(t.sm4Key), data, true)
if err == nil {
dataRes = fmt.Sprintf("\"%s\"", hex.EncodeToString(ecbMsg))
@ -159,7 +159,7 @@ func (t *Transport) ResponseEncoderWithEncryptFilter(noEncrypt map[string]bool)
dataRes := string(data)
// 正式服加密
if t.env == enum.Env_Production && !noEncrypt[r.URL.Path] {
if t.env == enum.Env_production && !noEncrypt[r.URL.Path] {
ecbMsg, err := sm4.Sm4Ecb([]byte(t.sm4Key), data, true)
if err == nil {
dataRes = fmt.Sprintf("\"%s\"", hex.EncodeToString(ecbMsg))
@ -183,7 +183,7 @@ func (t *Transport) ResponseEncoderWithEncryptFilter(noEncrypt map[string]bool)
func (t *Transport) ErrorEncoder() http.EncodeErrorFunc {
return func(w stdhttp.ResponseWriter, r *stdhttp.Request, err error) {
se := errors.FromError(err)
if t.env == enum.Env_Production {
if t.env == enum.Env_production {
if _, ok := err.(*errors.Error); !ok {
se = ErrInternalServer
}

Loading…
Cancel
Save