ing
This commit is contained in:
parent
529bab00a6
commit
445bab7d74
|
@ -116,9 +116,14 @@ func (rr *rpcRegistry) Invoke(contentType string, r io.Reader, w io.Writer, befo
|
|||
}
|
||||
// Call the service method.
|
||||
reply := reflect.New(methodSpec.replyType)
|
||||
// errValue := methodSpec.method.Func.Call([]reflect.Value{
|
||||
// serviceSpec.rcvr,
|
||||
// reflect.ValueOf(r),
|
||||
// args,
|
||||
// reply,
|
||||
// })
|
||||
errValue := methodSpec.method.Func.Call([]reflect.Value{
|
||||
serviceSpec.rcvr,
|
||||
reflect.ValueOf(r),
|
||||
args,
|
||||
reply,
|
||||
})
|
||||
|
|
|
@ -3,7 +3,6 @@ package rpc
|
|||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"strings"
|
||||
"sync"
|
||||
|
@ -14,7 +13,7 @@ import (
|
|||
var (
|
||||
// Precompute the reflect.Type of error and http.Request
|
||||
typeOfError = reflect.TypeOf((*error)(nil)).Elem()
|
||||
typeOfRequest = reflect.TypeOf((*http.Request)(nil)).Elem()
|
||||
// typeOfRequest = reflect.TypeOf((*http.Request)(nil)).Elem()
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -72,25 +71,40 @@ func (m *serviceMap) register(rcvr interface{}, name string) error {
|
|||
if method.PkgPath != "" {
|
||||
continue
|
||||
}
|
||||
// Method needs four ins: receiver, *http.Request, *args, *reply.
|
||||
if mtype.NumIn() != 4 {
|
||||
// // Method needs four ins: receiver, *http.Request, *args, *reply.
|
||||
// if mtype.NumIn() != 4 {
|
||||
// continue
|
||||
// }
|
||||
// // First argument must be a pointer and must be http.Request.
|
||||
// reqType := mtype.In(1)
|
||||
// if reqType.Kind() != reflect.Ptr || reqType.Elem() != typeOfRequest {
|
||||
// continue
|
||||
// }
|
||||
// // Second argument must be a pointer and must be exported.
|
||||
// args := mtype.In(2)
|
||||
// if args.Kind() != reflect.Ptr || !isExportedOrBuiltin(args) {
|
||||
// continue
|
||||
// }
|
||||
// // Third argument must be a pointer and must be exported.
|
||||
// reply := mtype.In(3)
|
||||
// if reply.Kind() != reflect.Ptr || !isExportedOrBuiltin(reply) {
|
||||
// continue
|
||||
// }
|
||||
// Method needs four ins: receiver, *args, *reply.
|
||||
if mtype.NumIn() != 3 {
|
||||
continue
|
||||
}
|
||||
// First argument must be a pointer and must be http.Request.
|
||||
reqType := mtype.In(1)
|
||||
if reqType.Kind() != reflect.Ptr || reqType.Elem() != typeOfRequest {
|
||||
continue
|
||||
}
|
||||
// Second argument must be a pointer and must be exported.
|
||||
args := mtype.In(2)
|
||||
// First argument must be a pointer and must be exported.
|
||||
args := mtype.In(1)
|
||||
if args.Kind() != reflect.Ptr || !isExportedOrBuiltin(args) {
|
||||
continue
|
||||
}
|
||||
// Third argument must be a pointer and must be exported.
|
||||
reply := mtype.In(3)
|
||||
// Second argument must be a pointer and must be exported.
|
||||
reply := mtype.In(2)
|
||||
if reply.Kind() != reflect.Ptr || !isExportedOrBuiltin(reply) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Method needs one out: error.
|
||||
if mtype.NumOut() != 1 {
|
||||
continue
|
||||
|
|
Loading…
Reference in New Issue
Block a user