|
|
@@ -109,6 +109,14 @@ func wrapServiceHandler(handler ServiceHandler) gin.HandlerFunc {
|
|
|
xmeta = "tenant=" + tenant
|
|
|
}
|
|
|
|
|
|
+ serviceMethod := r.Header.Get(XServiceMethod)
|
|
|
+ if serviceMethod != "" {
|
|
|
+ if xmeta != "" {
|
|
|
+ xmeta = xmeta + "&"
|
|
|
+ }
|
|
|
+ xmeta = xmeta + "reqMethod=" + servicePath + "." + serviceMethod
|
|
|
+ }
|
|
|
+
|
|
|
// 传递ClientIP和UserAgent
|
|
|
x_Meta := r.Header.Get("X-RPCX-Meta")
|
|
|
if x_Meta != "" && strings.Contains(x_Meta, "need_clint_Info=1") {
|
|
|
@@ -164,10 +172,10 @@ func wrapServiceHandler(handler ServiceHandler) gin.HandlerFunc {
|
|
|
// 普通开发环境改为json格式
|
|
|
env := r.Header.Get("SrvEnv")
|
|
|
if env == "dev" {
|
|
|
- ctx.Data(http.StatusOK, "application/json", payload)
|
|
|
+ ctx.Data(http.StatusOK, "application/json; charset=UTF-8", payload)
|
|
|
} else {
|
|
|
// 常规数据流
|
|
|
- ctx.Data(http.StatusOK, "application/octet-stream", payload)
|
|
|
+ ctx.Data(http.StatusOK, "application/octet-stream; charset=UTF-8", payload)
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
@@ -182,7 +190,6 @@ func wrapServiceHandler(handler ServiceHandler) gin.HandlerFunc {
|
|
|
//wh.Set(XMessageStatusType, "Error")
|
|
|
//wh.Set(XErrorMessage, err.Error())
|
|
|
//ctx.String(http.StatusOK, err.Error())
|
|
|
- //resp := errorJson(500, err.Error())
|
|
|
resp := errorJson(500, err.Error())
|
|
|
if err.Error() == "InvalidToken" {
|
|
|
resp.Code = 401
|
|
|
@@ -195,7 +202,7 @@ func (s *Server) Serve() error {
|
|
|
return s.g.Run(s.addr)
|
|
|
}
|
|
|
|
|
|
-// JsonResponse 数据返回通用JSON数据结构
|
|
|
+// 数据返回通用JSON数据结构
|
|
|
type JsonResponse struct {
|
|
|
Code int `json:"code,omitempty"` // 错误码((200:成功, 其他是异常)
|
|
|
Msg string `json:"msg,omitempty"` // 提示信息
|