mirror of
https://github.com/smallnest/rpcx.git
synced 2025-11-03 02:03:20 +08:00
39 lines
990 B
Go
39 lines
990 B
Go
package share
|
|
|
|
import (
|
|
"github.com/smallnest/rpcx/codec"
|
|
"github.com/smallnest/rpcx/protocol"
|
|
)
|
|
|
|
const (
|
|
// DefaultRPCPath is used by ServeHTTP.
|
|
DefaultRPCPath = "/_rpcx_"
|
|
|
|
// AuthKey is used in metadata.
|
|
AuthKey = "__AUTH"
|
|
)
|
|
|
|
var (
|
|
// Codecs are codecs supported by rpcx. You can add customized codecs in Codecs.
|
|
Codecs = map[protocol.SerializeType]codec.Codec{
|
|
protocol.SerializeNone: &codec.ByteCodec{},
|
|
protocol.JSON: &codec.JSONCodec{},
|
|
protocol.ProtoBuffer: &codec.PBCodec{},
|
|
protocol.MsgPack: &codec.MsgpackCodec{},
|
|
}
|
|
)
|
|
|
|
// RegisterCodec register customized codec.
|
|
func RegisterCodec(t protocol.SerializeType, c codec.Codec) {
|
|
Codecs[t] = c
|
|
}
|
|
|
|
// ContextKey defines key type in context.
|
|
type ContextKey string
|
|
|
|
// ReqMetaDataKey is used to set metatdata in context of requests.
|
|
var ReqMetaDataKey = ContextKey("__req_metadata")
|
|
|
|
// ResMetaDataKey is used to set metatdata in context of responses.
|
|
var ResMetaDataKey = ContextKey("__res_metadata")
|