httputils

package
v0.15.6 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommandHandler

func CommandHandler(commandHandler eh.CommandHandler, commandType eh.CommandType) http.Handler

CommandHandler is a HTTP handler for eventhorizon.Commands. Commands must be registered with eventhorizon.RegisterCommand(). It expects a POST with a JSON body that will be unmarshaled into the command.

func QueryHandler

func QueryHandler(repo eh.ReadRepo) http.Handler

QueryHandler returns one or all items from a eventhorizon.ReadRepo. If the URL ends with a / it will return all items, otherwise it will try to use the last part of the path as an ID to return one item.

Types

type EventBusHandler

type EventBusHandler struct {
	// contains filtered or unexported fields
}

EventBusHandler is a simple event handler for observing events.

func NewEventBusHandler added in v0.15.6

func NewEventBusHandler() *EventBusHandler

NewEventBusHandler creates a new EventBusHandler.

func (*EventBusHandler) HandleEvent added in v0.15.6

func (h *EventBusHandler) HandleEvent(ctx context.Context, event eh.Event) error

HandleEvent implements the HandleEvent method of the eventhorizon.EventHandler interface.

func (*EventBusHandler) HandlerType added in v0.15.6

func (h *EventBusHandler) HandlerType() eh.EventHandlerType

HandlerType implements the HandlerType method of the eventhorizon.EventHandler interface.

func (*EventBusHandler) ServeHTTP added in v0.15.6

func (h *EventBusHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the ServeHTTP method of the http.Handler interface by upgrading requests to websocket connections which will receive all events.

Jump to

Keyboard shortcuts

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