micro-server-grpc/handler.go
Vasiliy Tolstov 75c9d467e7
Some checks failed
prbuild / test (pull_request) Failing after 2m37s
prbuild / lint (pull_request) Successful in 5m19s
codeql / analyze (go) (pull_request) Failing after 10m32s
update for latest micro
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-27 01:25:15 +03:00

39 lines
661 B
Go

package grpc
import (
"reflect"
"go.unistack.org/micro/v3/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
}