Files
micro-server-grpc/handler.go
Evstigneev Denis c0d186327e
Some checks failed
lint / lint (pull_request) Failing after 1m38s
test / test (pull_request) Successful in 3m20s
prepare v4
2025-02-26 21:33:13 +03:00

39 lines
661 B
Go

package grpc
import (
"reflect"
"go.unistack.org/micro/v4/server"
)
type rpcHandler struct {
opts server.HandlerOptions
handler interface{}
name string
}
func newRPCHandler(handler interface{}, opts ...server.HandlerOption) server.Handler {
options := server.NewHandlerOptions(opts...)
hdlr := reflect.ValueOf(handler)
name := reflect.Indirect(hdlr).Type().Name()
return &rpcHandler{
name: name,
handler: handler,
opts: options,
}
}
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
}