mirror of
https://github.com/go-micro/go-micro.git
synced 2025-06-12 22:07:47 +02:00
Make json/protobuf codecs
This commit is contained in:
@ -5,6 +5,8 @@ import (
|
||||
errs "errors"
|
||||
|
||||
"github.com/micro/go-micro/codec"
|
||||
"github.com/micro/go-micro/codec/json"
|
||||
"github.com/micro/go-micro/codec/proto"
|
||||
"github.com/micro/go-micro/codec/jsonrpc"
|
||||
"github.com/micro/go-micro/codec/protorpc"
|
||||
"github.com/micro/go-micro/errors"
|
||||
@ -65,9 +67,9 @@ var (
|
||||
defaultContentType = "application/octet-stream"
|
||||
|
||||
defaultCodecs = map[string]codec.NewCodec{
|
||||
"application/json": jsonrpc.NewCodec,
|
||||
"application/protobuf": proto.NewCodec,
|
||||
"application/json": json.NewCodec,
|
||||
"application/json-rpc": jsonrpc.NewCodec,
|
||||
"application/protobuf": protorpc.NewCodec,
|
||||
"application/proto-rpc": protorpc.NewCodec,
|
||||
"application/octet-stream": protorpc.NewCodec,
|
||||
}
|
||||
@ -110,7 +112,7 @@ func (c *rpcCodec) WriteRequest(req *request, body interface{}) error {
|
||||
Method: req.ServiceMethod,
|
||||
Type: codec.Request,
|
||||
Header: map[string]string{
|
||||
"X-Micro-Target": req.Service,
|
||||
"X-Micro-Service": req.Service,
|
||||
"X-Micro-Method": req.ServiceMethod,
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user