Documentation
¶
Index ¶
- func Version() string
- type ContextHandlerFunc
- type ContextMiddlewareFunc
- type Group
- func (g *Group) AddContextEndpoint(name string, handler ContextHandlerFunc, opts ...micro.EndpointOpt) error
- func (g *Group) AddEndpoint(name string, handler micro.Handler, opts ...micro.EndpointOpt) error
- func (g *Group) AddGroup(name string, opts ...micro.GroupOpt) *Group
- func (g *Group) AddMicroEndpoint(name string, handler MicroHandlerFunc, opts ...micro.EndpointOpt) error
- func (g *Group) Use(fns ...MiddlewareFunc) *Group
- func (g *Group) UseContext(fns ...ContextMiddlewareFunc) *Group
- func (g *Group) UseMicro(fns ...MicroMiddlewareFunc) *Group
- func (g *Group) WithContextMiddleware(fns ...ContextMiddlewareFunc) *Group
- func (g *Group) WithMicroMiddleware(fns ...MicroMiddlewareFunc) *Group
- func (g *Group) WithMiddleware(fns ...MiddlewareFunc) *Group
- type HandlerError
- type MicroHandlerFunc
- type MicroMiddlewareFunc
- type MicroReply
- type MicroRequest
- func (r *MicroRequest) Context() context.Context
- func (r *MicroRequest) HeaderAdd(key, value string)
- func (r *MicroRequest) HeaderDel(key string)
- func (r *MicroRequest) HeaderGet(key string) string
- func (r *MicroRequest) HeaderSet(key, value string)
- func (r *MicroRequest) HeaderValues(key string) []string
- func (r *MicroRequest) WithContext(ctx context.Context) *MicroRequest
- type MiddlewareFunc
- type Request
- type Service
- func AddContextService(nc *nats.Conn, config micro.Config, fns ...ContextMiddlewareFunc) (*Service, error)
- func AddMicroService(nc *nats.Conn, config micro.Config, fns ...MicroMiddlewareFunc) (*Service, error)
- func AddService(nc *nats.Conn, config micro.Config, fns ...MiddlewareFunc) (*Service, error)
- func (s *Service) AddContextEndpoint(name string, handler ContextHandlerFunc, opts ...micro.EndpointOpt) error
- func (s *Service) AddEndpoint(name string, handler micro.Handler, opts ...micro.EndpointOpt) error
- func (s *Service) AddGroup(name string, opts ...micro.GroupOpt) *Group
- func (s *Service) AddMicroEndpoint(name string, handler MicroHandlerFunc, opts ...micro.EndpointOpt) error
- func (s *Service) Info() micro.Info
- func (s *Service) Reset()
- func (s *Service) SetDefaultContext(ctx context.Context)
- func (s *Service) Stats() micro.Stats
- func (s *Service) Stop() error
- func (s *Service) Stopped() bool
- func (s *Service) Use(fns ...MiddlewareFunc) *Service
- func (s *Service) UseContext(fns ...ContextMiddlewareFunc) *Service
- func (s *Service) UseMicro(fns ...MicroMiddlewareFunc) *Service
- func (s *Service) WithContextMiddleware(fns ...ContextMiddlewareFunc) *Service
- func (s *Service) WithMicroMiddleware(fns ...MicroMiddlewareFunc) *Service
- func (s *Service) WithMiddleware(fns ...MiddlewareFunc) *Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ContextHandlerFunc ¶
type ContextMiddlewareFunc ¶
type ContextMiddlewareFunc func(ContextHandlerFunc) ContextHandlerFunc
Middleware function that takes a `ContextHandlerFunc` and returns a new `ContextHandlerFunc`
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group represents a Microservice group with middleware support.
func (*Group) AddContextEndpoint ¶
func (g *Group) AddContextEndpoint(name string, handler ContextHandlerFunc, opts ...micro.EndpointOpt) error
AddContextEndpoint registers an endpoint with the given name on a specific subject within a group.
func (*Group) AddEndpoint ¶
AddEndpoint registers new endpoints on a service. The endpoint's subject will be prefixed with the group prefix.
func (*Group) AddMicroEndpoint ¶ added in v0.1.0
func (g *Group) AddMicroEndpoint(name string, handler MicroHandlerFunc, opts ...micro.EndpointOpt) error
AddMicroEndpoint registers an endpoint with the given name on a specific subject within a group.
func (*Group) Use ¶
func (g *Group) Use(fns ...MiddlewareFunc) *Group
Use is an alias for WithMiddleware, adding middleware functions to the Microservice group.
func (*Group) UseContext ¶
func (g *Group) UseContext(fns ...ContextMiddlewareFunc) *Group
UseContext is an alias for WithContextMiddleware, adding context middleware functions to the Microservice group.
func (*Group) UseMicro ¶ added in v0.1.0
func (g *Group) UseMicro(fns ...MicroMiddlewareFunc) *Group
UseMicro is an alias for WithMicroMiddleware, adding Micro middleware functions to the Microservice group.
func (*Group) WithContextMiddleware ¶
func (g *Group) WithContextMiddleware(fns ...ContextMiddlewareFunc) *Group
WithContextMiddleware adds context middleware functions to the Microservice group.
func (*Group) WithMicroMiddleware ¶ added in v0.1.0
func (g *Group) WithMicroMiddleware(fns ...MicroMiddlewareFunc) *Group
WithMicroMiddleware adds Micro middleware functions to the Microservice group.
func (*Group) WithMiddleware ¶
func (g *Group) WithMiddleware(fns ...MiddlewareFunc) *Group
WithMiddleware adds middleware functions to the Microservice group.
type HandlerError ¶
func (*HandlerError) Error ¶
func (e *HandlerError) Error() string
type MicroHandlerFunc ¶ added in v0.1.0
type MicroHandlerFunc func(*MicroRequest) (*MicroReply, error)
type MicroMiddlewareFunc ¶ added in v0.1.0
type MicroMiddlewareFunc func(MicroHandlerFunc) MicroHandlerFunc
type MicroReply ¶ added in v0.1.0
func NewMicroReply ¶ added in v0.1.0
func NewMicroReply(data []byte) *MicroReply
Create a new MicroReply
func NewMicroReplyFromRequest ¶ added in v0.1.0
func NewMicroReplyFromRequest(data []byte, req *MicroRequest) *MicroReply
Create a new MicroReply and copy headers from the original request
func (*MicroReply) HeaderAdd ¶ added in v0.1.0
func (r *MicroReply) HeaderAdd(key, value string)
func (*MicroReply) HeaderDel ¶ added in v0.1.0
func (r *MicroReply) HeaderDel(key string)
func (*MicroReply) HeaderGet ¶ added in v0.1.0
func (r *MicroReply) HeaderGet(key string) string
func (*MicroReply) HeaderSet ¶ added in v0.1.0
func (r *MicroReply) HeaderSet(key, value string)
func (*MicroReply) HeaderValues ¶ added in v0.1.0
func (r *MicroReply) HeaderValues(key string) []string
type MicroRequest ¶ added in v0.1.0
type MicroRequest struct { Subject string Reply string Headers micro.Headers Data []byte // contains filtered or unexported fields }
func (*MicroRequest) Context ¶ added in v0.1.0
func (r *MicroRequest) Context() context.Context
Context returns the current attached message context.
func (*MicroRequest) HeaderAdd ¶ added in v0.1.0
func (r *MicroRequest) HeaderAdd(key, value string)
func (*MicroRequest) HeaderDel ¶ added in v0.1.0
func (r *MicroRequest) HeaderDel(key string)
func (*MicroRequest) HeaderGet ¶ added in v0.1.0
func (r *MicroRequest) HeaderGet(key string) string
func (*MicroRequest) HeaderSet ¶ added in v0.1.0
func (r *MicroRequest) HeaderSet(key, value string)
func (*MicroRequest) HeaderValues ¶ added in v0.1.0
func (r *MicroRequest) HeaderValues(key string) []string
func (*MicroRequest) WithContext ¶ added in v0.1.0
func (r *MicroRequest) WithContext(ctx context.Context) *MicroRequest
WithContext sets a new message context and returns a new MicroRequest.
type MiddlewareFunc ¶
MiddlewareFunc defines the type for middleware functions.
type Request ¶
Request extends the micro.Request type to include a custom context.
func (*Request) RespondWithOriginalHeaders ¶ added in v0.0.2
func (r *Request) RespondWithOriginalHeaders(response []byte, opts ...micro.RespondOpt) error
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service represents a Microservice with middleware support.
func AddContextService ¶
func AddContextService(nc *nats.Conn, config micro.Config, fns ...ContextMiddlewareFunc) (*Service, error)
AddContextService creates a new Microservice with middleware support. Note that this version does not support defining an endpoint in the initial config. If any is defined, it will not use any of the context-based middlewares.
func AddMicroService ¶ added in v0.1.0
func AddMicroService(nc *nats.Conn, config micro.Config, fns ...MicroMiddlewareFunc) (*Service, error)
AddMicroService creates a new Microservice with middleware support. Note that this version does not support defining an endpoint in the initial config. If any is defined, it will not use any of the context-based middlewares.
func AddService ¶
func AddService(nc *nats.Conn, config micro.Config, fns ...MiddlewareFunc) (*Service, error)
AddService creates a new Microservice with middleware support.
func (*Service) AddContextEndpoint ¶
func (s *Service) AddContextEndpoint(name string, handler ContextHandlerFunc, opts ...micro.EndpointOpt) error
AddContextEndpoint registers an endpoint with the given name on a specific subject.
func (*Service) AddEndpoint ¶
AddEndpoint registers an endpoint with the given name on a specific subject.
func (*Service) AddGroup ¶
AddGroup returns a Group interface, allowing for more complex endpoint topologies. A group can be used to register endpoints with a given prefix.
func (*Service) AddMicroEndpoint ¶ added in v0.1.0
func (s *Service) AddMicroEndpoint(name string, handler MicroHandlerFunc, opts ...micro.EndpointOpt) error
AddMicroEndpoint registers an endpoint with the given name on a specific subject.
func (*Service) Reset ¶
func (s *Service) Reset()
Reset resets all statistics (for all endpoints) on a service instance.
func (*Service) SetDefaultContext ¶
SetDefaultContext sets the default context to be used by the service. This context will be used if no custom context is provided during endpoint registration.
func (*Service) Stats ¶
Stats returns statistics for the service endpoint and all monitoring endpoints.
func (*Service) Use ¶
func (s *Service) Use(fns ...MiddlewareFunc) *Service
Use is an alias for WithMiddleware, adding middleware functions to the Microservice.
func (*Service) UseContext ¶
func (s *Service) UseContext(fns ...ContextMiddlewareFunc) *Service
UseContext is an alias for WithContextMiddleware, adding middleware functions to the Microservice.
func (*Service) UseMicro ¶ added in v0.1.0
func (s *Service) UseMicro(fns ...MicroMiddlewareFunc) *Service
UseMicro is an alias for WithMicroMiddleware, adding middleware functions to the Microservice.
func (*Service) WithContextMiddleware ¶
func (s *Service) WithContextMiddleware(fns ...ContextMiddlewareFunc) *Service
WithContextMiddleware adds middleware functions to the Microservice.
func (*Service) WithMicroMiddleware ¶ added in v0.1.0
func (s *Service) WithMicroMiddleware(fns ...MicroMiddlewareFunc) *Service
WithMicroMiddleware adds middleware functions to the Microservice.
func (*Service) WithMiddleware ¶
func (s *Service) WithMiddleware(fns ...MiddlewareFunc) *Service
WithMiddleware adds middleware functions to the Microservice.