pages

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Routes = []RouteInfo{
	{Pattern: "GET /{$}", Path: "/", Dir: "", Params: nil},
	{Pattern: "GET /about", Path: "/about", Dir: "about", Params: nil},
	{Pattern: "GET /users/{id}", Path: "/users/{id}", Dir: "users/id_", Params: []string{"id"}},
}

Routes lists what the filesystem knows about each route, so a framework can build a sitemap or an inspector without a metadata format.

Functions

func BindLayout

func BindLayout(params LayoutParams) htmlbind.Wrapper

BindLayout binds Layout as a chain wrapper filling its unnamed slot.

func Layout

func Layout(params LayoutParams) htmlbind.Fragment

Layout binds Layout to its parameters, producing a renderable fragment.

func NewServeMux

func NewServeMux(options ...htmlbind.Option) *http.ServeMux

NewServeMux returns a ServeMux carrying every discovered route.

func Page

func Page(params PageParams) htmlbind.Fragment

Page binds Page to its parameters, producing a renderable fragment.

func Register

func Register(mux *http.ServeMux, options ...htmlbind.Option)

Register installs every discovered route on mux.

Options are passed to the runtime on each render, so a caller supplies its per-request cache, timeout, and error hook here.

Types

type LayoutParams

type LayoutParams struct {
	Children htmlbind.Fragment
}

type PageParams

type PageParams struct{}

type RouteInfo

type RouteInfo struct {
	// Pattern is the stdlib ServeMux pattern the route is registered under.
	Pattern string
	// Path is the pattern without its method.
	Path string
	// Dir is the route directory relative to the route root.
	Dir string
	// Params names the dynamic segments, in route order.
	Params []string
}

RouteInfo is one entry of Routes.

type RouteParams

type RouteParams struct {
}

RouteParams holds the URL inputs of GET /{$}.

func DecodeRoute

func DecodeRoute(r *http.Request) (RouteParams, error)

DecodeRoute reads the path and query values of GET /{$}. An unparsable value produces an error rather than a zero value.

Directories

Path Synopsis
users
id_

Jump to

Keyboard shortcuts

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