api/handler/rpc: fix corner cases
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
fa9ef1c816
commit
e3f235acc1
@ -250,7 +250,9 @@ func requestPayload(r *http.Request) ([]byte, error) {
|
||||
}
|
||||
return raw.Marshal()
|
||||
case strings.Contains(ct, "application/www-x-form-urlencoded"):
|
||||
r.ParseForm()
|
||||
if err = r.ParseForm(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// generate a new set of values from the form
|
||||
vals := make(map[string]string, len(r.Form))
|
||||
|
@ -2,12 +2,12 @@ package rpc
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
go_api "github.com/unistack-org/micro/v3/api/proto"
|
||||
jsonpb "google.golang.org/protobuf/encoding/protojson"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func TestRequestPayloadFromRequest(t *testing.T) {
|
||||
@ -22,7 +22,7 @@ func TestRequestPayloadFromRequest(t *testing.T) {
|
||||
t.Fatal("Failed to marshal proto", err)
|
||||
}
|
||||
|
||||
jsonBytes, err := json.Marshal(protoEvent)
|
||||
jsonBytes, err := jsonpb.Marshal(&protoEvent)
|
||||
if err != nil {
|
||||
t.Fatal("Failed to marshal proto to JSON ", err)
|
||||
}
|
||||
|
@ -44,6 +44,8 @@ func serveWebsocket(ctx context.Context, w http.ResponseWriter, r *http.Request,
|
||||
case "binary":
|
||||
hdr["Sec-WebSocket-Protocol"] = []string{"binary"}
|
||||
op = ws.OpBinary
|
||||
default:
|
||||
op = ws.OpBinary
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user