micro-server-grpc/handler.go

39 lines
661 B
Go
Raw Normal View History

2019-06-03 18:44:43 +01:00
package grpc
import (
"reflect"
"go.unistack.org/micro/v3/server"
2019-06-03 18:44:43 +01:00
)
type rpcHandler struct {
opts server.HandlerOptions
handler interface{}
name string
2019-06-03 18:44:43 +01:00
}
func newRPCHandler(handler interface{}, opts ...server.HandlerOption) server.Handler {
options := server.NewHandlerOptions(opts...)
2019-06-03 18:44:43 +01:00
hdlr := reflect.ValueOf(handler)
name := reflect.Indirect(hdlr).Type().Name()
return &rpcHandler{
name: name,
handler: handler,
opts: options,
2019-06-03 18:44:43 +01:00
}
}
func (r *rpcHandler) Name() string {
return r.name
}
func (r *rpcHandler) Handler() interface{} {
return r.handler
}
func (r *rpcHandler) Options() server.HandlerOptions {
return r.opts
}