rewriting a lot
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user