dcsunny преди 4 години
родител
ревизия
83309f5817
променени са 2 файла, в които са добавени 7 реда и са изтрити 5 реда
  1. 3 1
      http/middleware/rpc_value.go
  2. 4 4
      http/param/base.go

+ 3 - 1
http/middleware/rpc_value.go

@@ -3,6 +3,7 @@ package middleware
 import (
 	"context"
 	"encoding/json"
+	"fmt"
 	"net/url"
 	"strconv"
 
@@ -53,7 +54,8 @@ func GrpcValue(handler middleware.Handler) middleware.Handler {
 			}
 			body := md.Get("body")
 			if len(body) > 0 {
-				ctx = context2.AppendToContext(ctx, "body", []byte(body[0]))
+				fmt.Println(body)
+				ctx = context2.AppendToContext(ctx, "body", body[0])
 			}
 			uri := md.Get("uri")
 			if len(uri) > 0 {

+ 4 - 4
http/param/base.go

@@ -21,12 +21,12 @@ func GetFromPath(c context.Context) string {
 	return ""
 }
 
-func GetBody(c context.Context) []byte {
+func GetBody(c context.Context) string {
 	body := c.Value("body")
-	if _, ok := body.([]byte); ok {
-		return body.([]byte)
+	if _, ok := body.(string); ok {
+		return body.(string)
 	}
-	return nil
+	return ""
 }
 
 func GetUri(c context.Context) string {