web

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

Package web is the driving HTTP adapter: it serves the Templ + htmx UI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCSRFToken

func NewCSRFToken() string

NewCSRFToken returns a random per-process CSRF token.

func Secure

func Secure(next http.Handler, csrfToken string) http.Handler

Secure rejects requests that did not come from a page served on localhost: the Host and Origin headers must name a loopback host (a DNS-rebinding defence), the browser must not mark the request as coming from another site, and every mutating request must carry the CSRF token in the X-CSRF-Token header or a csrf_token form field.

Types

type Deps

type Deps struct {
	// CSRFToken must accompany every mutating request.
	CSRFToken string
	Review    *review.Service
	Settings  settings.Store
	Hub       *live.Hub // live updates for open pages
	Servers   *servers.Service
	ThemesDir string             // drop-in Themes; may be empty
	Metrics   *metrics.Collector // optional: the Settings page's Activity panel
	// Dev relaxes the Content-Security-Policy for a live-reload proxy.
	Dev bool
}

Deps are what the Server serves from.

type Server

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

Server serves the UI.

func NewServer

func NewServer(d Deps) *Server

NewServer returns a Server over d.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the root handler with the security middleware applied.

Directories

Path Synopsis
Package views holds the Templ components for the UI.
Package views holds the Templ components for the UI.

Jump to

Keyboard shortcuts

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