presentation

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

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

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

Documentation

Overview

Package presentation owns Petclinic's HTTP presentation infrastructure.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCatalog

func NewCatalog() (*i18n.Catalog, error)

NewCatalog constructs the immutable Petclinic message catalog.

@Bean

func NewMux

func NewMux() (*http.ServeMux, error)

NewMux returns an instance-owned Go 1.22 pattern-aware HTTP mux with immutable embedded assets.

@Bean @Fallback

func NewRenderer

func NewRenderer(catalog *i18n.Catalog) (*view.Renderer, error)

NewRenderer parses all Petclinic templates once during construction.

@Bean

Types

type ErrorModel

type ErrorModel struct {
	Page   Page
	Status int
	Title  string
	Detail string
}

ErrorModel is the safe browser-facing error page model.

type Page

type Page struct {
	Locale string
	Active string
}

Page carries shared layout and locale state for one rendered response.

func NewPage

func NewPage(catalog interface{ Resolve(string) string }, language, active string) Page

NewPage resolves a request language and identifies the active navigation item.

type Server

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

Server owns the Petclinic HTTP listener and graceful-drain lifecycle.

func NewServer

func NewServer(
	settings ServerSettings,
	handler *http.ServeMux,
) (*Server, error)

NewServer constructs a lifecycle-managed server with bounded timeouts.

@Bean

func (*Server) Address

func (server *Server) Address() string

Address returns the bound address, or the configured address before start.

func (*Server) Start

func (server *Server) Start(ctx context.Context) error

Start binds the configured listener.

@OnStart

func (*Server) Stop

func (server *Server) Stop(ctx context.Context) error

Stop gracefully drains the listener and observes its serve result.

@OnStop

type ServerSettings

type ServerSettings struct {
	Address           string        `spice:"address,default=127.0.0.1:8080,env=SPICE_PETCLINIC_ADDRESS"`
	ReadHeaderTimeout time.Duration `spice:"read-header-timeout,default=5s"`
	ReadTimeout       time.Duration `spice:"read-timeout,default=15s"`
	WriteTimeout      time.Duration `spice:"write-timeout,default=15s"`
	IdleTimeout       time.Duration `spice:"idle-timeout,default=60s"`
}

ServerSettings contains safe Petclinic HTTP server defaults.

@Configuration(prefix="petclinic.server")

Jump to

Keyboard shortcuts

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