Documentation ¶
Index ¶
- func MatchServeMuxPattern(mux *http.ServeMux, dir LookupHTTPHandler) (handler http.Handler, pattern string)
- type BusHandler
- type HTTPHandler
- type HTTPHandlerBuilder
- type HTTPHandlerController
- func (c *HTTPHandlerController) Close() error
- func (c *HTTPHandlerController) Execute(ctx context.Context) error
- func (c *HTTPHandlerController) GetControllerInfo() *controller.Info
- func (c *HTTPHandlerController) HandleDirective(ctx context.Context, inst directive.Instance) ([]directive.Resolver, error)
- type LookupHTTPHandler
- type LookupHTTPHandlerResolver
- type LookupHTTPHandlerValue
- func ExLookupFirstHTTPHandler(ctx context.Context, b bus.Bus, handlerMethod string, handlerURL *url.URL, ...) (LookupHTTPHandlerValue, directive.Instance, directive.Reference, error)
- func ExLookupHTTPHandlers(ctx context.Context, b bus.Bus, handlerMethod string, handlerURL *url.URL, ...) ([]LookupHTTPHandlerValue, directive.Instance, directive.Reference, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MatchServeMuxPattern ¶ added in v0.33.2
func MatchServeMuxPattern(mux *http.ServeMux, dir LookupHTTPHandler) (handler http.Handler, pattern string)
MatchServeMuxPattern matches a LookupHTTPMethod against at ServeMux.
Types ¶
type BusHandler ¶ added in v0.7.8
type BusHandler struct {
// contains filtered or unexported fields
}
BusHandler implements http.Handler by calling LookupHTTPHandler.
func NewBusHandler ¶ added in v0.7.8
func NewBusHandler(b bus.Bus, clientID string, notFoundIfIdle bool) *BusHandler
NewBusHandler constructs a new bus-backed HTTP handler.
func (*BusHandler) ServeHTTP ¶ added in v0.7.8
func (h *BusHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)
ServeHTTP serves the http request.
type HTTPHandler ¶ added in v0.7.8
type HTTPHandler struct {
// contains filtered or unexported fields
}
HTTPHandler implements a HTTP handler which deduplicates with a reference count.
func NewBusHTTPHandler ¶ added in v0.7.9
func NewBusHTTPHandler( ctx context.Context, b bus.Bus, baseMethod string, baseURL *url.URL, clientID string, notFoundIfIdle bool, ) *HTTPHandler
NewBusHTTPHandler constructs a HTTPHandler which looks up the HTTP handler on the bus when at least one request is active.
baseMethod can be empty to allow any baseURL is the URL to use for the client lookup.
func NewHTTPHandler ¶ added in v0.7.8
func NewHTTPHandler( ctx context.Context, builder HTTPHandlerBuilder, ) *HTTPHandler
NewHTTPHandler constructs a new HTTPHandler.
NOTE: if ctx == nil the handler won't work until SetContext is called.
func (*HTTPHandler) ServeHTTP ¶ added in v0.7.8
func (h *HTTPHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)
ServeHTTP serves a http request.
func (*HTTPHandler) SetContext ¶ added in v0.7.8
func (h *HTTPHandler) SetContext(ctx context.Context)
SetContext sets the context for the HTTPHandler.
type HTTPHandlerBuilder ¶ added in v0.7.8
type HTTPHandlerBuilder = refcount.RefCountResolver[http.Handler]
HTTPHandlerBuilder builds a HTTP Handle.
returns the http handler and an optional release function can return nil to indicate not found.
func NewBusHTTPHandlerBuilder ¶ added in v0.7.8
func NewBusHTTPHandlerBuilder(b bus.Bus, baseMethod string, baseURL *url.URL, clientID string, notFoundIfIdle bool) HTTPHandlerBuilder
NewBusHTTPHandlerBuilder constructs a HTTPHandlerBuilder which looks up the handler on the bus.
baseMethod can be empty to allow any
func NewHTTPHandlerBuilder ¶ added in v0.7.8
func NewHTTPHandlerBuilder(handler http.Handler) HTTPHandlerBuilder
NewHTTPHandlerBuilder creates a new HTTPHandlerBuilder with a static handler.
type HTTPHandlerController ¶ added in v0.7.8
type HTTPHandlerController struct {
// contains filtered or unexported fields
}
HTTPHandlerController resolves LookupHTTPHandler with a http.Handler.
func NewHTTPHandlerController ¶ added in v0.7.8
func NewHTTPHandlerController( info *controller.Info, resolver HTTPHandlerBuilder, pathPrefixes []string, stripPathPrefix bool, pathRe *regexp.Regexp, ) *HTTPHandlerController
NewHTTPHandlerController constructs a new controller.
Responds if a URL matches either pathPrefixes OR pathRe. pathPrefixes and pathRe can be empty. if stripPathPrefix is set, removes the pathPrefix from the URL.
func (*HTTPHandlerController) Close ¶ added in v0.7.8
func (c *HTTPHandlerController) Close() error
Close releases any resources used by the controller.
func (*HTTPHandlerController) Execute ¶ added in v0.7.8
func (c *HTTPHandlerController) Execute(ctx context.Context) error
Execute executes the controller.
func (*HTTPHandlerController) GetControllerInfo ¶ added in v0.7.8
func (c *HTTPHandlerController) GetControllerInfo() *controller.Info
GetControllerInfo returns information about the controller.
func (*HTTPHandlerController) HandleDirective ¶ added in v0.7.8
func (c *HTTPHandlerController) HandleDirective( ctx context.Context, inst directive.Instance, ) ([]directive.Resolver, error)
HandleDirective asks if the handler can resolve the directive.
type LookupHTTPHandler ¶
type LookupHTTPHandler interface { // Directive indicates LookupHTTPHandler is a directive. directive.Directive // LookupHTTPHandlerMethod is the method string for the request. // Can be empty to allow any. LookupHTTPHandlerMethod() string // LookupHTTPHandlerURL is the URL for the request. LookupHTTPHandlerURL() *url.URL // LookupHTTPHandlerClientID is a string identifying the client. // Can be empty. LookupHTTPHandlerClientID() string }
LookupHTTPHandler is a directive to lookup a HTTP handler.
func NewLookupHTTPHandler ¶
func NewLookupHTTPHandler(handlerMethod string, handlerURL *url.URL, clientID string) LookupHTTPHandler
NewLookupHTTPHandler constructs a new LookupHTTPHandler directive. handlerMethod can be empty to allow any.
type LookupHTTPHandlerResolver ¶
type LookupHTTPHandlerResolver struct {
// contains filtered or unexported fields
}
LookupHTTPHandlerResolver resolves LookupHTTPHandler with a handler.
func NewLookupHTTPHandlerResolver ¶
func NewLookupHTTPHandlerResolver(handler http.Handler) *LookupHTTPHandlerResolver
NewLookupHTTPHandlerResolver constructs a new resolver.
func (*LookupHTTPHandlerResolver) Resolve ¶
func (r *LookupHTTPHandlerResolver) Resolve(ctx context.Context, handler directive.ResolverHandler) error
Resolve resolves the values, emitting them to the handler.
type LookupHTTPHandlerValue ¶
LookupHTTPHandlerValue is the result type for LookupHTTPHandler. Multiple results may be pushed to the directive.
func ExLookupFirstHTTPHandler ¶
func ExLookupFirstHTTPHandler( ctx context.Context, b bus.Bus, handlerMethod string, handlerURL *url.URL, clientID string, returnIfIdle bool, valDisposeCb func(), ) (LookupHTTPHandlerValue, directive.Instance, directive.Reference, error)
ExLookupFirstHTTPHandler waits for the first HTTP handler to be returned. if returnIfIdle is set and the directive becomes idle, returns nil, nil, nil, handlerMethod can be empty to allow any.
func ExLookupHTTPHandlers ¶
func ExLookupHTTPHandlers( ctx context.Context, b bus.Bus, handlerMethod string, handlerURL *url.URL, clientID string, waitOne bool, ) ([]LookupHTTPHandlerValue, directive.Instance, directive.Reference, error)
ExLookupHTTPHandlers executes the LookupHTTPHandler directive. If waitOne is set, waits for at least one value before returning. handlerMethod can be empty to allow any.