Documentation
¶
Overview ¶
Package rest provides a wrapper around of mux service (rest grpc) implementations.
Index ¶
- type HandlerPathFunc
- type HandlerPathOption
- type InitRESTServiceConfig
- type Option
- func WithAddrAssigned() Option
- func WithAddress(addr string) Option
- func WithHandlerPathOption(opts ...HandlerPathFunc) Option
- func WithListener(l net.Listener, shouldCloseListener bool) Option
- func WithPort(port int) Option
- func WithServerMuxOption(opts ...runtime.ServeMuxOption) Option
- func WithService(s ServiceServer) Option
- type Server
- type ServiceHandlerServerFunc
- type ServiceServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HandlerPathFunc ¶
HandlerPathFunc allows users to configure custom path handlers for mux service.
type HandlerPathOption ¶
type HandlerPathOption struct { // Method is the http method used in the route/path. Method string // PathPattern the http route path. PathPattern string // Handler is what to do when the request fulfil the method and path pattern. Handler func(w http.ResponseWriter, r *http.Request, _ map[string]string) }
HandlerPathOption allows users to configure custom path handlers. The struct is used along with HandlerPathFunc when configuring custom path handlers for the mux service.
type InitRESTServiceConfig ¶
type InitRESTServiceConfig struct { Listener net.Listener Service ServiceServer UInterceptor []grpc.UnaryServerInterceptor Handlers []HandlerPathOption Options []Option ResponseModifier func(context.Context, http.ResponseWriter, proto.Message) error }
type Option ¶
type Option func(mux *Server)
Option sets up a server mux.
func WithAddrAssigned ¶
func WithAddrAssigned() Option
WithAddrAssigned sets service to ask for listener assigned address. Mainly used when the port to the listener is assigned dynamically.
func WithHandlerPathOption ¶
func WithHandlerPathOption(opts ...HandlerPathFunc) Option
WithHandlerPathOption sets the options for custom path handlers to the mux server.
func WithListener ¶
WithListener sets the listener. Server does not need to start a new one.
func WithServerMuxOption ¶
func WithServerMuxOption(opts ...runtime.ServeMuxOption) Option
WithServerMuxOption sets the options for the mux server.
type Server ¶
type Server struct { AddrAssigned chan string // contains filtered or unexported fields }
Server is a wrapper around runtime.Server.
func InitRESTService ¶
func InitRESTService( _ context.Context, cfg InitRESTServiceConfig, ) (*Server, error)
InitRESTService initialize an instance of REST service based on the GRPC service.
func (*Server) WithShutdownSignal ¶
func (s *Server) WithShutdownSignal(shutdown <-chan struct{}, done chan<- struct{}) servicing.Service
WithShutdownSignal adds channels to wait for shutdown and to report shutdown finished.
type ServiceHandlerServerFunc ¶
ServiceHandlerServerFunc is the function to register the http handlers for service to "mux".
type ServiceServer ¶
type ServiceServer interface { RegisterHandlerService(mux *runtime.ServeMux) error WithUnaryServerInterceptor(i grpc.UnaryServerInterceptor) ServiceServer }
ServiceServer is an interface for a server that provides services.