uiversion

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 14 Imported by: 0

README

caddy-ui-version

Caddy HTTP handler that selects a UI document-root name from a SQLite database keyed by request host, and exposes it as {http.vars.ui_version}.

Caddyfile

{
	order ui_version before root
}

:80 {
	ui_version {
		sqlite /ui-versions.sqlite
		default original
	}

	root * /{http.vars.ui_version}
	file_server
}

SQLite schema

CREATE TABLE domains (
  name TEXT PRIMARY KEY NOT NULL,
  ui_version TEXT NOT NULL
);

name is the bare hostname (lowercase, no port). Missing hosts use default (typically original).

The sample DB maps dagplannen.nlmodern.

Build

xcaddy build --with github.com/randock/caddy-ui-version@v0.0.1

Sample database

go run ./cmd/mksampledb -o ui-versions.sqlite

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UIVersion

type UIVersion struct {
	// SQLite is the path to the domains database.
	SQLite string `json:"sqlite,omitempty"`

	// Default is used when the host is missing from the database.
	Default string `json:"default,omitempty"`
	// contains filtered or unexported fields
}

UIVersion looks up the Host header in a SQLite database and sets {http.vars.ui_version} so later directives (e.g. root) can select a site tree.

func (UIVersion) CaddyModule

func (UIVersion) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*UIVersion) Cleanup

func (m *UIVersion) Cleanup() error

Cleanup closes the database.

func (*UIVersion) Provision

func (m *UIVersion) Provision(ctx caddy.Context) error

Provision sets up the module.

func (UIVersion) ServeHTTP

func (m UIVersion) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error

ServeHTTP implements caddyhttp.MiddlewareHandler.

func (*UIVersion) UnmarshalCaddyfile

func (m *UIVersion) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile implements caddyfile.Unmarshaler.

ui_version {
    sqlite /ui-versions.sqlite
    default original
}

func (*UIVersion) Validate

func (m *UIVersion) Validate() error

Validate implements caddy.Validator.

Directories

Path Synopsis
cmd
mksampledb command

Jump to

Keyboard shortcuts

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