Documentation ¶
Index ¶
- Constants
- Variables
- func CopyHTTPHeader(source http.Header) metadata.MD
- func CopyMetadataHeader(header metadata.MD) http.Header
- func GetMethodEndpoint(method *specs.Method) (string, string, error)
- func LookupEndpointReferences(method *Method, store refs.Store) string
- func NewCaller() transport.NewCaller
- func NewListener(addr string, opts specs.Options) transport.NewListener
- func NewProxy(options *CallerOptions) *httputil.ReverseProxy
- func NewRequest(req *http.Request) *transport.Request
- func SetHTTPHeader(writer http.Header, metadata metadata.MD)
- func TemplateReferences(value string, functions functions.Custom) ([]*specs.Property, error)
- type Call
- type Caller
- type CallerOptions
- type EndpointOptions
- type Handle
- type Listener
- type ListenerOptions
- type Method
- type Proxy
- type Request
- type ResponseWriter
- type TransportResponseWriter
Constants ¶
const ( // InsecureOption connection flag InsecureOption = "insecure" // CAFileOption certificate authority file path CAFileOption = "ca_file" // CertFileOption certificate file path CertFileOption = "cert_file" // KeyFileOption certificate key file path KeyFileOption = "key_file" // ReadTimeoutOption represents the HTTP read timeout option key ReadTimeoutOption = "read_timeout" // WriteTimeoutOption represents the HTTP write timeout option key WriteTimeoutOption = "write_timeout" // EndpointOption represents the HTTP endpoints option key EndpointOption = "endpoint" // MethodOption represents the HTTP method option key MethodOption = "method" // CodecOption represents the HTTP listener codec option key CodecOption = "codec" // FlushIntervalOption represents the flush interval option key FlushIntervalOption = "flush_interval" // TimeoutOption represents the timeout option key TimeoutOption = "timeout" // KeepAliveOption represents the keep alive option key KeepAliveOption = "keep_alive" // MaxIdleConnsOption represents the max idle connections option key MaxIdleConnsOption = "max_idle_conns" )
const ContentTypeHeaderKey = "Content-Type"
ContentTypeHeaderKey represents the HTTP header content type key
Variables ¶
var ContentTypes = map[string]string{
"json": "application/json",
}
ContentTypes represents a lists of available codec content types and their Content-Type value
var ReferenceLookup = regexp.MustCompile(`(?m):[a-zA-Z\d\^\&\%\$@\_\-\.]+`)
ReferenceLookup is executed to lookup references within a given endpoint. A reference starts with a colon and could contain characters, numbers, underscores and hyphens and dots to define nested properties
Functions ¶
func CopyHTTPHeader ¶
CopyHTTPHeader copies the given HTTP header into a transport header
func CopyMetadataHeader ¶
CopyMetadataHeader copies the given transport header into a HTTP header
func GetMethodEndpoint ¶
GetMethodEndpoint attempts to find the endpoint for the given method. Empty values are returned when a empty method name is given.
func LookupEndpointReferences ¶
LookupEndpointReferences looks up the references within the given endpoint and returns the newly constructed endpoint
func NewListener ¶
func NewListener(addr string, opts specs.Options) transport.NewListener
NewListener constructs a new listener for the given addr
func NewProxy ¶
func NewProxy(options *CallerOptions) *httputil.ReverseProxy
NewProxy constructs a new reverse proxy with the given options
func NewRequest ¶
NewRequest constructs a new transport request of the given http request
func SetHTTPHeader ¶
SetHTTPHeader copies the given transport header into a HTTP header
Types ¶
type Call ¶
type Call struct {
// contains filtered or unexported fields
}
Call represents the HTTP caller implementation
func (*Call) GetMethods ¶
GetMethods returns the available methods within the HTTP caller
type Caller ¶
type Caller struct {
// contains filtered or unexported fields
}
Caller represents the caller constructor
type CallerOptions ¶
type CallerOptions struct { Timeout time.Duration KeepAlive time.Duration FlushInterval time.Duration MaxIdleConns int Insecure bool CAFile string }
CallerOptions represents the available HTTP options
func ParseCallerOptions ¶
func ParseCallerOptions(options specs.Options) (*CallerOptions, error)
ParseCallerOptions parses the given specs options into HTTP options
type EndpointOptions ¶
type EndpointOptions struct { Method string Endpoint string ReadTimeout time.Duration WriteTimeout time.Duration Codec string }
EndpointOptions represents the available HTTP options
func ParseEndpointOptions ¶
func ParseEndpointOptions(options specs.Options) (*EndpointOptions, error)
ParseEndpointOptions parses the given specs options into HTTP options
type Handle ¶
type Handle struct { *transport.Endpoint Options *EndpointOptions Proxy *Proxy // contains filtered or unexported fields }
Handle holds a endpoint its options and a optional request and response
func NewHandle ¶
func NewHandle(ctx instance.Context, endpoint *transport.Endpoint, options *EndpointOptions, constructors map[string]codec.Constructor) (*Handle, error)
NewHandle constructs a new handle function for the given endpoint to the given flow
func (*Handle) HTTPFunc ¶
func (handle *Handle) HTTPFunc(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
HTTPFunc represents a HTTP function which could be used inside a HTTP router
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener represents a HTTP listener
func (*Listener) Handle ¶
func (listener *Listener) Handle(ctx instance.Context, endpoints []*transport.Endpoint, codecs map[string]codec.Constructor) error
Handle parses the given endpoints and constructs route handlers
func (*Listener) HandleCors ¶
HandleCors handles the defining of cors headers for the incoming HTTP request
type ListenerOptions ¶
type ListenerOptions struct { ReadTimeout time.Duration WriteTimeout time.Duration CertFile string KeyFile string }
ListenerOptions represents the available HTTP options
func ParseListenerOptions ¶
func ParseListenerOptions(options specs.Options) (*ListenerOptions, error)
ParseListenerOptions parses the given specs options into HTTP options
type Method ¶
type Method struct {
// contains filtered or unexported fields
}
Method represents a service method
func (*Method) References ¶
References returns the available method references
type Proxy ¶
type Proxy struct { Handle *httputil.ReverseProxy Header *metadata.Manager }
Proxy represents a HTTP reverse proxy
type ResponseWriter ¶
type ResponseWriter struct {
// contains filtered or unexported fields
}
A ResponseWriter interface is used by an HTTP handler to construct an HTTP response.
func NewResponseWriter ¶
func NewResponseWriter(rw http.ResponseWriter) *ResponseWriter
NewResponseWriter constructs a new HTTP response writer of the given HTTP response writer
func (*ResponseWriter) Header ¶
func (rw *ResponseWriter) Header() metadata.MD
Header returns the header map that will be sent by WriteHeader. The Header map also is the mechanism with which Handlers can set HTTP trailers.
func (*ResponseWriter) Write ¶
func (rw *ResponseWriter) Write(bb []byte) (int, error)
Write writes the data to the connection as part of an HTTP reply.
func (*ResponseWriter) WriteHeader ¶
func (rw *ResponseWriter) WriteHeader(status int)
WriteHeader sends an HTTP response header with the provided status code.
type TransportResponseWriter ¶
type TransportResponseWriter struct {
// contains filtered or unexported fields
}
A TransportResponseWriter interface is used by an HTTP handler to construct an HTTP response.
func NewTransportResponseWriter ¶
func NewTransportResponseWriter(ctx context.Context, rw transport.ResponseWriter) *TransportResponseWriter
NewTransportResponseWriter constructs a new HTTP response writer of the given transport response writer
func (*TransportResponseWriter) AwaitStatus ¶
func (rw *TransportResponseWriter) AwaitStatus()
AwaitStatus awaits till the response header status code has been written
func (*TransportResponseWriter) Header ¶
func (rw *TransportResponseWriter) Header() http.Header
Header returns the header map that will be sent by WriteHeader. The Header map also is the mechanism with which Handlers can set HTTP trailers.
func (*TransportResponseWriter) Write ¶
func (rw *TransportResponseWriter) Write(bb []byte) (int, error)
Write writes the data to the connection as part of an HTTP reply.
func (*TransportResponseWriter) WriteHeader ¶
func (rw *TransportResponseWriter) WriteHeader(status int)
WriteHeader sends an HTTP response header with the provided status code.