rewriting a lot

This commit is contained in:
Asim Aslam
2019-01-09 19:11:47 +00:00
parent 1561ccbc14
commit 873fc6d663
5 changed files with 79 additions and 15 deletions

View File

@@ -2,13 +2,16 @@ package server
import (
"github.com/micro/go-micro/codec"
"github.com/micro/go-micro/transport"
)
type rpcRequest struct {
service string
method string
contentType string
socket transport.Socket
codec codec.Codec
header map[string]string
body []byte
stream bool
}
@@ -35,8 +38,26 @@ func (r *rpcRequest) Method() string {
return r.method
}
func (r *rpcRequest) Body() []byte {
return r.body
func (r *rpcRequest) Header() map[string]string {
return r.header
}
func (r *rpcRequest) Read() ([]byte, error) {
// got a body
if r.body != nil {
b := r.body
r.body = nil
return b, nil
}
var msg transport.Message
err := r.socket.Recv(&msg)
if err != nil {
return nil, err
}
r.header = msg.Header
return msg.Body, nil
}
func (r *rpcRequest) Stream() bool {