This commit is contained in:
crusader 2017-10-27 14:24:46 +09:00
parent f22f37a6dc
commit f7cd07b3cc
3 changed files with 2 additions and 6 deletions

View File

@ -10,6 +10,8 @@ import (
// Codec creates a CodecRequest to process each request.
type Codec interface {
// NewRequest is constructor of new request object
// error io.ErrUnexpectedEOF or io.EOF
NewRequest(rc io.Reader) (CodecRequest, error)
}

View File

@ -3,7 +3,6 @@ package json
import (
"encoding/json"
"io"
"log"
"git.loafle.net/commons_go/rpc/encode"
"git.loafle.net/commons_go/rpc/protocol"
@ -86,7 +85,6 @@ func newCodecRequest(r io.Reader, encoder encode.Encoder) (protocol.CodecRequest
req := new(serverRequest)
err := json.NewDecoder(r).Decode(req)
if err == io.ErrUnexpectedEOF || err == io.EOF {
log.Printf("NewRequest err: %v", err)
return nil, err
}
if err != nil {

View File

@ -3,7 +3,6 @@ package rpc
import (
"fmt"
"io"
"log"
"reflect"
"strings"
@ -99,19 +98,16 @@ func (rr *rpcRegistry) Invoke(contentType string, r io.Reader, w io.Writer, befo
return fmt.Errorf("Unrecognized Content-Type: %s", contentType)
}
log.Print("codec.NewRequest")
// Create a new codec request.
codecReq, errNew := codec.NewRequest(r)
if nil != errNew {
return errNew
}
// Get service method to be called.
log.Printf("codecReq.Method: %v", codecReq)
method, errMethod := codecReq.Method()
if errMethod != nil {
return write(codecReq, w, beforeWrite, afterWrite, nil, errMethod)
}
log.Print("rr.services.get")
serviceSpec, methodSpec, errGet := rr.services.get(method)
if errGet != nil {
return write(codecReq, w, beforeWrite, afterWrite, nil, errGet)