web

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package web is a platform module: server rendered pages next to the API — templ components, htmx fragments, CSRF protection, sealed cookies and hashed static assets from kit/webx. Pages are plain routes of the api module, so they share its server, its request ids, metrics and access log.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// SecretKey seals cookies; at least 32 bytes. Changing it signs every visitor out of
	// their unfinished forms, nothing more.
	SecretKey []byte
	// InsecureCookies allows cookies over plain http: local development only.
	InsecureCookies bool
}

Config holds module settings.

func Load

func Load(l *confx.Loader) Config

Load reads the module settings from environment variables.

type Kit

type Kit struct {
	CSRF    *webx.CSRF
	Cookies *webx.Cookies
	// Secure tells whether cookies are marked Secure.
	Secure bool
}

Kit is what pages use: the CSRF protection and the sealed cookies.

func From

func From(app *platform.App) *Kit

From returns the kit from the container.

type Module

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

Module implements platform.Module.

func New

func New(cfg Config) *Module

New builds the module.

func (*Module) Init

func (m *Module) Init(_ context.Context, app *platform.App) error

Init puts the kit into the container.

func (*Module) Name

func (m *Module) Name() string

Name implements platform.Module.

Jump to

Keyboard shortcuts

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