web

package
v0.0.0-...-6d7befa Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MethodGET    = "GET"
	MethodPOST   = "POST"
	MethodPUT    = "PUT"
	MethodDELETE = "DELETE"

	CacheControlHeader = "Cache-Control"
	ContentTypeHeader  = "Content-Type"
	ETagHeader         = "ETag"
	LocationHeader     = "Location"

	ContentTypeAtom = "application/atom+xml"
	ContentTypeHTML = "text/html"
	ContentTypeJSON = "application/json"
	ContentTypeText = "text/plain; charset=UTF-8"
)

Variables

This section is empty.

Functions

func BaseMiddleware

func BaseMiddleware(next http.Handler) http.Handler

func ControllerMiddleware

func ControllerMiddleware(handler Handler) http.Handler

func MaxAgeMiddleware

func MaxAgeMiddleware(next http.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
	Middleware []HandlerProvider
}

func NewAssetController

func NewAssetController(basePath string, 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 HandlerProvider

type HandlerProvider func(http.Handler) http.Handler

type MessageHandler

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

type SitemapController

type SitemapController struct {
	Controller
	// contains filtered or unexported fields
}

func NewSitemapController

func NewSitemapController() *SitemapController

func (*SitemapController) AddSite

func (sc *SitemapController) AddSite(url url.URL)

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(patterns ...string) (*template.Template, error)

func (*Templater) GetP

func (t *Templater) GetP(patterns ...string) *template.Template

func (*Templater) Write

func (t *Templater) Write(writer io.Writer, data any, patterns ...string) 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