ing
This commit is contained in:
parent
f22f37a6dc
commit
f7cd07b3cc
|
@ -10,6 +10,8 @@ import (
|
||||||
|
|
||||||
// Codec creates a CodecRequest to process each request.
|
// Codec creates a CodecRequest to process each request.
|
||||||
type Codec interface {
|
type Codec interface {
|
||||||
|
// NewRequest is constructor of new request object
|
||||||
|
// error io.ErrUnexpectedEOF or io.EOF
|
||||||
NewRequest(rc io.Reader) (CodecRequest, error)
|
NewRequest(rc io.Reader) (CodecRequest, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package json
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
|
||||||
|
|
||||||
"git.loafle.net/commons_go/rpc/encode"
|
"git.loafle.net/commons_go/rpc/encode"
|
||||||
"git.loafle.net/commons_go/rpc/protocol"
|
"git.loafle.net/commons_go/rpc/protocol"
|
||||||
|
@ -86,7 +85,6 @@ func newCodecRequest(r io.Reader, encoder encode.Encoder) (protocol.CodecRequest
|
||||||
req := new(serverRequest)
|
req := new(serverRequest)
|
||||||
err := json.NewDecoder(r).Decode(req)
|
err := json.NewDecoder(r).Decode(req)
|
||||||
if err == io.ErrUnexpectedEOF || err == io.EOF {
|
if err == io.ErrUnexpectedEOF || err == io.EOF {
|
||||||
log.Printf("NewRequest err: %v", err)
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -3,7 +3,6 @@ package rpc
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"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)
|
return fmt.Errorf("Unrecognized Content-Type: %s", contentType)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("codec.NewRequest")
|
|
||||||
// Create a new codec request.
|
// Create a new codec request.
|
||||||
codecReq, errNew := codec.NewRequest(r)
|
codecReq, errNew := codec.NewRequest(r)
|
||||||
if nil != errNew {
|
if nil != errNew {
|
||||||
return errNew
|
return errNew
|
||||||
}
|
}
|
||||||
// Get service method to be called.
|
// Get service method to be called.
|
||||||
log.Printf("codecReq.Method: %v", codecReq)
|
|
||||||
method, errMethod := codecReq.Method()
|
method, errMethod := codecReq.Method()
|
||||||
if errMethod != nil {
|
if errMethod != nil {
|
||||||
return write(codecReq, w, beforeWrite, afterWrite, nil, errMethod)
|
return write(codecReq, w, beforeWrite, afterWrite, nil, errMethod)
|
||||||
}
|
}
|
||||||
log.Print("rr.services.get")
|
|
||||||
serviceSpec, methodSpec, errGet := rr.services.get(method)
|
serviceSpec, methodSpec, errGet := rr.services.get(method)
|
||||||
if errGet != nil {
|
if errGet != nil {
|
||||||
return write(codecReq, w, beforeWrite, afterWrite, nil, errGet)
|
return write(codecReq, w, beforeWrite, afterWrite, nil, errGet)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user