web

package
v0.0.0-...-66e2244 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2023 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseMiddleware

func BaseMiddleware(next http.Handler) http.Handler

func ControllerMiddleware

func ControllerMiddleware(handler Handler) http.Handler

func StaticContentMiddleware

func StaticContentMiddleware(next http.Handler) http.Handler

Types

type CloseHandler

type CloseHandler func()

type Controller

type Controller struct {
	BasePath string
	Handlers map[Endpoint]Handler
}

func NewAssetController

func NewAssetController(fileSystem fs.FS) *Controller

func NewTemplateController

func NewTemplateController(fileSystem fs.FS, data any) *Controller

func (*Controller) Register

func (c *Controller) Register(router chi.Router)

type Endpoint

type Endpoint struct {
	Path   string
	Method string
}

type Handler

type Handler func(http.ResponseWriter, *http.Request) error

type MessageHandler

type MessageHandler func(client *WSClient, msg string) error

type Templater

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

func NewTemplater

func NewTemplater(fileSystem fs.FS) *Templater

func (*Templater) Get

func (t *Templater) Get(templatePath string) (*template.Template, error)

func (*Templater) Write

func (t *Templater) Write(templatePath string, writer io.Writer, data any) error

type WSClient

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

func NewWSClient

func NewWSClient(conn *websocket.Conn, onMessage MessageHandler, onClose CloseHandler) *WSClient

func (*WSClient) Close

func (c *WSClient) Close() error

func (*WSClient) WriteMessage

func (c *WSClient) WriteMessage(msg string)

Jump to

Keyboard shortcuts

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