handler

package
v0.0.0-...-1c404c5 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Game

func Game(env *Env, w http.ResponseWriter, r *http.Request) (int, error)

Game creates, updates, or loads a game.

func Live

func Live(ws *websocket.Conn)

Live sends game updates to a WebSocket connection.

func LoadTemplates

func LoadTemplates(path string) map[string]*template.Template

LoadTemplates loads all templates into memory (layout and content)

func RenderTemplate

func RenderTemplate(env *Env, w http.ResponseWriter, name string, data interface{}) error

RenderTemplate renders an HTML template from the cache using provided data

func Static

func Static(env *Env, w http.ResponseWriter, r *http.Request) (int, error)

Static responds to static routes not covered by another handler.

Types

type Env

type Env struct {
	Templates    map[string]*template.Template
	TemplatePath string
}

Env holds a map of cached templates.

type Handler

type Handler struct {
	*Env
	Fn func(*Env, http.ResponseWriter, *http.Request) (int, error)
}

Handler wraps a route handler with an Env.

func (Handler) ServeHTTP

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

ServeHTTP is called on a reqHandler by net/http; satisfies http.Handler.

Jump to

Keyboard shortcuts

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