bifrost_http

package
v0.32.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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,
	baseURL, 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.

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, baseURL, clientID string, notFoundIfIdle bool) HTTPHandlerBuilder

NewBusHTTPHandlerBuilder constructs a HTTPHandlerBuilder which looks up the handler on the bus.

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

	// LookupHTTPHandlerURL is the URL string for the request.
	// Cannot be empty.
	LookupHTTPHandlerURL() string

	// 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(handlerURL, clientID string) LookupHTTPHandler

NewLookupHTTPHandler constructs a new LookupHTTPHandler directive.

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

Resolve resolves the values, emitting them to the handler.

type LookupHTTPHandlerValue

type LookupHTTPHandlerValue = http.Handler

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,
	handlerURL,
	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,

func ExLookupHTTPHandlers

func ExLookupHTTPHandlers(
	ctx context.Context,
	b bus.Bus,
	handlerURL,
	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.

Directories

Path Synopsis
log

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL