Documentation ¶
Index ¶
- func NewService(n string, v string) *service
- func URLToServiceName(host string, path string) string
- func URLToServiceVersion(path string) string
- type HandlerWrapper
- type HttpHandlerFunc
- type HttpHandlerWrapper
- type HttpResponseWrapper
- type HttpResponseWriter
- type Option
- func Context(c context.Context) Option
- func Registry(r registry.Registry) Option
- func Router(r router.Router) Option
- func Selector(s selector.Selector) Option
- func Transport(t transport.Transport) Option
- func WrapHandler(w ...HandlerWrapper) Option
- func WrapRepsWriter(w ...HttpResponseWrapper) Option
- type Options
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewService ¶
func URLToServiceName ¶
URLToServiceName builds the service name for a internal transport use from an URL
func URLToServiceVersion ¶
URLToServiceVersion builds the service version for a internal transport use from an URL
Types ¶
type HandlerWrapper ¶
HandlerWrapper wraps the HandlerFunc and returns the equivalent
type HttpHandlerFunc ¶
type HttpHandlerFunc func(http.ResponseWriter, *http.Request)
HttpHandlerFunc represents a single method of a http handler. It's used primarily for the wrappers.
func HttpWrapperChain ¶
func HttpWrapperChain(f HttpHandlerFunc, m ...HttpHandlerWrapper) HttpHandlerFunc
HttpWrapperChain builds the wrapper chain recursively, functions are first class
type HttpHandlerWrapper ¶
type HttpHandlerWrapper func(HttpHandlerFunc) HttpHandlerFunc
HttpHandlerWrapper wraps the HttpHandlerFunc and returns the equivalent
type HttpResponseWrapper ¶
type HttpResponseWrapper func(HttpResponseWriter) HttpResponseWriter
type HttpResponseWriter ¶
type HttpResponseWriter func(http.ResponseWriter, *codec.Message)
type Option ¶
type Option func(*Options)
func WrapHandler ¶
func WrapHandler(w ...HandlerWrapper) Option
WrapHandler adds a service handler Wrapper to a list of options passed into the server
func WrapRepsWriter ¶
func WrapRepsWriter(w ...HttpResponseWrapper) Option
WrapHandler adds a service handler Wrapper to a list of options passed into the server
type Options ¶
type Options struct { Transport transport.Transport Registry registry.Registry Router router.Router Context context.Context Selector selector.Selector //wrappers HdlrWrappers []HandlerWrapper HttpRespWrappers []HttpResponseWrapper }
Options of a service
type Service ¶
type Service interface { Name() string Version() string ID() string Options() Options Config() map[string]string ServerHandler(*nats.Msg) ApiHandler(*nats.Msg) Init(...Option) error Run() error Stop() error Respond(*codec.Message, string) error Pub(string, string, *codec.Message) error Req(string, string, *codec.Message, transport.ResponseHandler) error }