1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-06-12 22:07:47 +02:00

For the legacy

This commit is contained in:
Asim Aslam
2019-01-18 10:12:57 +00:00
parent 9ce9977d21
commit 2cd2258731
14 changed files with 99 additions and 21 deletions

View File

@ -97,17 +97,23 @@ func (s *rpcServer) ServeConn(sock transport.Socket) {
ct = DefaultContentType
}
// TODO: needs better error handling
cf, err := s.newCodec(ct)
if err != nil {
sock.Send(&transport.Message{
Header: map[string]string{
"Content-Type": "text/plain",
},
Body: []byte(err.Error()),
})
s.wg.Done()
return
// setup old protocol
cf := setupProtocol(&msg)
// no old codec
if cf == nil {
// TODO: needs better error handling
var err error
if cf, err = s.newCodec(ct); err != nil {
sock.Send(&transport.Message{
Header: map[string]string{
"Content-Type": "text/plain",
},
Body: []byte(err.Error()),
})
s.wg.Done()
return
}
}
rcodec := newRpcCodec(&msg, sock, cf)
@ -115,6 +121,7 @@ func (s *rpcServer) ServeConn(sock transport.Socket) {
// internal request
request := &rpcRequest{
service: msg.Header["X-Micro-Service"],
method: msg.Header["X-Micro-Method"],
endpoint: msg.Header["X-Micro-Endpoint"],
contentType: ct,
codec: rcodec,