Files
micro-server-grpc/handler.go
Evstigneev Denis 23a1ff424e
All checks were successful
test / test (push) Successful in 1m53s
prepare v4 (need swap target!) (#195)
move to v4 micro

Co-authored-by: Vasiliy Tolstov <v.tolstov@unistack.org>
Reviewed-on: #195
Co-authored-by: Evstigneev Denis <danteevstigneev@yandex.ru>
Co-committed-by: Evstigneev Denis <danteevstigneev@yandex.ru>
2025-03-02 21:13:25 +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
}