httputils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2018 License: Apache-2.0 Imports: 8 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 unmarshalled into the command.

func EventBusHandler

func EventBusHandler(eventPublisher eh.EventPublisher) http.Handler

EventBusHandler is a Websocket handler for eventhorizon.Events. Events will be forwarded to all requests that have been upgraded to websockets. TODO: Send events as JSON.

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 Observer

type Observer struct {
	EventCh chan eh.Event
}

Observer is a simple event handler for observing events.

func (*Observer) Notify

func (o *Observer) Notify(ctx context.Context, event eh.Event)

Notify implements the Notify method of the EventObserver interface.

Jump to

Keyboard shortcuts

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