web

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: BSD-3-Clause Imports: 32 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package web holds the HTTP server, the routes, the middleware, the handlers and the server-sent event streams. It never imports internal/store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

Server is the HTTP server of Clowder: the routes, the middleware and the handlers. Make it with New.

func New

func New(cfg config.Config, logger *slog.Logger, svc Services) (*Server, error)

New makes the server from its dependencies. Run starts it. It fails when the embedded static files cannot be read and hashed.

func (*Server) Handler

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

Handler returns the whole handler stack: the security headers, request logging, panic recovery, cross-origin protection and the routes.

func (*Server) Run

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

Run listens on the configured address and serves until ctx is done. Then it stops accepting requests and waits for the running ones for 10 seconds (SPEC §8). It returns nil after a clean shutdown.

type Services

type Services struct {
	// Accounts is the service of login, sessions, invitations and users.
	Accounts *app.Accounts
	// Rooms is the service of rooms and their memberships.
	Rooms *app.Rooms
	// Audit is the service that reads the audit log.
	Audit *app.Audit
	// Posts is the service of posts, their tags and their feeds.
	Posts *app.Posts
	// Board is the service of the Kanban boards. The streams read it to find
	// the posts whose tasks a change of the columns concerns.
	Board *app.Board
	// Search is the service of search.
	Search *app.Search
	// Notifications is the service of the notifications of a user: their
	// unread count in the sidebar and their page.
	Notifications *app.Notifications
	// Messages is the service of private conversations and messages: their
	// pages, their streams and the unread count in the sidebar.
	Messages *app.Messages
	// Hub delivers the live events of the services to the streams of the
	// pages (SPEC §8). The services must publish to the same hub. Nil makes a
	// hub that nothing publishes to.
	Hub *live.Hub
}

Services are the services the handlers call. Later steps add a field for each service they build.

Directories

Path Synopsis
Package static holds the files the server sends as they are: the Datastar client, the stylesheet and the scripts.
Package static holds the files the server sends as they are: the Datastar client, the stylesheet and the scripts.
Package views holds the templ components and pages.
Package views holds the templ components and pages.

Jump to

Keyboard shortcuts

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