Documentation ¶
Index ¶
- Constants
- func StatusMessage(status int) string
- type Call
- type Caller
- type Callers
- type Endpoint
- type EndpointList
- type ErrMalformedTemplate
- type Error
- type Errs
- type Flow
- type Forward
- type Listener
- type ListenerList
- type Method
- type NewCaller
- type NewListener
- type Object
- func (object *Object) NewCodec(ctx *broker.Context, resource string, codec codec.Constructor) error
- func (object *Object) NewMeta(ctx *broker.Context, resource string)
- func (object *Object) ResolveMessage(store references.Store) string
- func (object *Object) ResolveStatusCode(store references.Store) int
- type Request
- type ResponseWriter
- type Rewrite
- type Writer
Constants ¶
const ( // StatusOK represents a 200 header status code StatusOK = 200 // StatusInternalErr represents a 500 header status code StatusInternalErr = 500 )
Variables ¶
This section is empty.
Functions ¶
func StatusMessage ¶
StatusMessage attempts to lookup the message for the given status code. If no message has been found fot the given status code is a empty string returned.
Types ¶
type Call ¶
type Call interface { SendMsg(ctx context.Context, writer ResponseWriter, request *Request, refs references.Store) error GetMethods() []Method GetMethod(name string) Method Close() error }
Call is a preconfigured interface for a single service
type Caller ¶
type Caller interface { Name() string Dial(service *specs.Service, functions functions.Custom, options specs.Options, resolver discovery.Resolver) (Call, error) }
Caller constructs new calls which could be used to call services
type Endpoint ¶
type Endpoint struct { Listener string Flow Flow Forward *Forward Options specs.Options Request *Object Response *Object Errs Errs }
Endpoint represents a transport listener endpoint
func NewEndpoint ¶
func NewEndpoint(listener string, flow Flow, forward *Forward, options specs.Options, request, response *specs.ParameterMap) *Endpoint
NewEndpoint constructs a new transport endpoint.
func (*Endpoint) NewCodec ¶
func (endpoint *Endpoint) NewCodec(ctx *broker.Context, request codec.Constructor, response codec.Constructor) (err error)
NewCodec updates the endpoint request and response codecs and metadata managers. If a forwarding service is set is the request codec ignored.
type EndpointList ¶
type EndpointList []*Endpoint
EndpointList represents a collection of transport endpoints
type ErrMalformedTemplate ¶
ErrMalformedTemplate is returned when unable to compile the URL template
func (ErrMalformedTemplate) Error ¶
func (e ErrMalformedTemplate) Error() string
type Error ¶
type Error interface { specs.ErrorHandle String() string Error() string Ptr() specs.ErrorHandle }
Error represents a wrapped error and error specs
type Errs ¶
type Errs map[specs.ErrorHandle]*Object
Errs represents a err object collection
type Flow ¶
type Flow interface { NewStore() references.Store GetName() string Errors() []Error Do(ctx context.Context, refs references.Store) error Wait() }
Flow represents a flow which could be called by a transport
type Forward ¶
type Forward struct { Schema specs.Header Meta *metadata.Manager Service *specs.Service Rewrite []Rewrite }
Forward represents the forward specifications
type Listener ¶
type Listener interface { Name() string Serve() error Close() error Handle(*broker.Context, []*Endpoint, map[string]codec.Constructor) error }
Listener specifies the listener implementation
type ListenerList ¶
type ListenerList []Listener
ListenerList represents a collection of listeners
func (ListenerList) Get ¶
func (collection ListenerList) Get(name string) Listener
Get attempts to return a listener with the given name
type NewListener ¶
NewListener constructs a new listener with the given context
type Object ¶
type Object struct { Definition *specs.ParameterMap StatusCode *specs.Property Message *specs.Property Codec codec.Manager Meta *metadata.Manager }
Object represents a data object.
func (*Object) NewCodec ¶
NewCodec updates the given object to use the given codec. Errors returned while constructing a new codec manager are returned.
func (*Object) ResolveMessage ¶
func (object *Object) ResolveMessage(store references.Store) string
ResolveMessage attempts to resolve the defined message. If no message property has been defined or the property is not a string. Is a internal server error message returned.
func (*Object) ResolveStatusCode ¶
func (object *Object) ResolveStatusCode(store references.Store) int
ResolveStatusCode attempts to resolve the defined status code. If no status code property has been defined or the property is not a int64. Is a internal server error status returned.
type Request ¶
type Request struct { RequestCodec string ResponseCodec string Header metadata.MD Method Method Body io.Reader }
Request represents the request object given to a caller implementation used to make calls
type ResponseWriter ¶
type ResponseWriter interface { io.WriteCloser Header() metadata.MD HeaderStatus(int) HeaderMessage(string) }
ResponseWriter specifies the response writer implementation which could be used to both proxy forward a request or used to call a service
type Rewrite ¶
Rewrite describes a function which is applied to modify the request URL. Returns modified URL and true or source URL and false if does not match.
func NewRewrite ¶
NewRewrite prepares a rewrite function to be called by the handler before forwarding the request to the proxy.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer represents a response writer
func NewResponseWriter ¶
func NewResponseWriter(writer io.WriteCloser) *Writer
NewResponseWriter constructs a new response writer for the given io writer
func (*Writer) HeaderMessage ¶
HeaderMessage sets the header message
func (*Writer) HeaderStatus ¶
HeaderStatus sets the header status