router

package
v0.0.0-...-08e1117 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All[T any](ts []T, pred func(T) bool) bool

func DoAll

func DoAll[T any](ts []T, pred func(T) error) error

Types

type HandlerFuncPair

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

type HandlerGenerator

type HandlerGenerator interface {
	// If a HandlerGenerator does not run a goroutine, then Run() and Halt() are no-ops and IsRunning and IsHalted() always return true
	Run() error // Run() should be idempotent
	Halt() error
	IsRunning() bool
	IsHalted() bool
	GetHttpHandlers() []*HandlerPair
}

Common server implementation boilerplate

type HandlerPair

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

func NewHandlerPair

func NewHandlerPair(path string, handler http.Handler) *HandlerPair

type Router

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

func NewRouter

func NewRouter() *Router

func (*Router) AddHandler

func (r *Router) AddHandler(path string, handler http.Handler)

func (*Router) AddHandlerFunc

func (r *Router) AddHandlerFunc(path string, handler http.HandlerFunc)

func (*Router) AddHandlerGen

func (r *Router) AddHandlerGen(handleGen HandlerGenerator)

func (*Router) GetHttpHandler

func (r *Router) GetHttpHandler() (path string, handler http.Handler)

func (*Router) Halt

func (r *Router) Halt() error

func (*Router) IsHalted

func (r *Router) IsHalted() bool

func (*Router) IsRunning

func (r *Router) IsRunning() bool

func (*Router) Run

func (r *Router) Run() error

implement HandlerGenerator for Router

Jump to

Keyboard shortcuts

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