web

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package web provides the HTTP server and web UI for wherehouse.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App interface {
	ListEntities(ctx context.Context) ([]app.EntityResult, error)
	GetEntityByID(ctx context.Context, entityID string) (app.EntityResult, error)
	GetChildren(ctx context.Context, parentID string) ([]app.EntityResult, error)
	GetHistory(ctx context.Context, req app.GetHistoryRequest) ([]app.HistoryResult, error)
	CreateEntity(ctx context.Context, req app.CreateEntityRequest) (app.EntityResult, error)
	RenameEntity(ctx context.Context, req app.RenameEntityRequest) (app.EntityResult, error)
	ChangeStatus(ctx context.Context, req app.ChangeStatusRequest) error
	FindEntities(ctx context.Context, req app.FindEntitiesRequest) ([]app.FindResult, error)
}

App is the dependency contract the web package requires from the app layer.

type Breadcrumb struct {
	Name     string
	EntityID string
}

Breadcrumb is one segment of the entity path shown above the detail heading. EntityID is empty for the last (current) crumb — it renders as plain text.

func BreadcrumbsForEntity(entities []app.EntityResult, fullPath string) []Breadcrumb

BreadcrumbsForEntity builds a breadcrumb slice from fullPath by matching each path prefix against the provided entity list. Exported for testing.

type Config

type Config struct {
	App    App
	Bind   string
	Port   int
	Output io.Writer      // destination for the startup URL line; defaults to os.Stdout
	Logger logging.Logger // structured logger; defaults to logging.GetLogger()
}

Config holds all configuration for the web server.

type Server

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

Server is the wherehouse web server.

func New

func New(cfg Config) (*Server, error)

New constructs a Server from cfg. Returns an error if template parsing fails.

func (*Server) Handler

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

Handler returns the underlying http.Handler (for use in httptest).

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run starts the HTTP server, prints the URL, and blocks until ctx is cancelled or an OS interrupt (SIGINT/SIGTERM) is received, then shuts down gracefully.

Jump to

Keyboard shortcuts

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