router

package
v0.0.0-...-82c6a1a Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventHandler

type EventHandler func(*websocket.Event, *websocket.Bus)

EventHandler - event handler struct.

type EventRouter

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

EventRouter - event handler map.

func NewEventRouter

func NewEventRouter() *EventRouter

NewEventRouter - initialization for event router.

func (*EventRouter) HandleEvent

func (ro *EventRouter) HandleEvent(ie *websocket.Event, b *websocket.Bus)

HandleEvent - handle event by handler.

func (*EventRouter) SetRoute

func (ro *EventRouter) SetRoute(op string, h EventHandler)

SetRoute - set route to the map.

type HttpRouter

type HttpRouter struct {
	http.ServeMux
}

HttpRouter - custom router structure.

func NewHttpRouter

func NewHttpRouter() *HttpRouter

NewHttpRouter - instantiate new http router.

func (*HttpRouter) AddIndexRoute

func (hr *HttpRouter) AddIndexRoute(pattern string, h httpHandler)

AddIndexRoute - add route handle for index page.

func (*HttpRouter) AddRoute

func (hr *HttpRouter) AddRoute(pattern string, h httpHandler)

AddRoute - add route handle for common page.

type WsHandler

type WsHandler func(*websocket.Bus, *EventRouter) int

type WsRouter

type WsRouter struct {
	http.ServeMux
	BeforeRouteCall func(http.ResponseWriter, *http.Request) *websocket.Bus
	// contains filtered or unexported fields
}

WsRouter - websocket router struct.

func NewWsRouter

func NewWsRouter() *WsRouter

NewWsRouter - instantiate new web socket router.

func (*WsRouter) AddEventRoute

func (wsr *WsRouter) AddEventRoute(op string, handler EventHandler)

AddEventRoute - add event route handler.

func (*WsRouter) AddIndexRoute

func (wsr *WsRouter) AddIndexRoute(pattern string, handler WsHandler)

AddIndexRoute - add route handle for index page. Where `id` - is newly added connection for client.

Jump to

Keyboard shortcuts

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