web
| Name | Summary |
|---|---|
assets |
Embedded static assets served via rust-embed. |
csrf |
CSRF protection middleware (signed-cookie double-submit pattern). |
forms |
Form-parsing helpers for the web handlers. |
gravatar |
Avatar URL helper. |
handlers |
HTTP handlers for the web dashboard, organized by domain. |
markdown |
Markdown-to-HTML renderer for the web layer using pulldown-cmark. |
nonce |
Per-request CSP nonce middleware. |
reload_ipc |
Unix domain socket listener that forwards bare connection signals to the SSE reload broadcast channel. |
request_log |
Request logging middleware. |
security_headers |
Security headers middleware. |
sse |
Server-sent events endpoint that pushes reload pings to connected browser tabs. |
state |
Shared application state handed to every axum handler. |
sync_export |
Export to .gest/ after each web write. |
timeline |
Unified activity timeline combining notes and semantic transaction events. |
enum Error
pub enum ErrorErrors produced by the web layer.
A single Error covers both the startup path (file watcher, socket bind, TCP
listener) and the request path (handler responses). The IntoResponse impl
maps variants to real HTTP status codes so handlers can return typed errors
instead of stringified 500s.
BadRequest and Internal carry user-facing messages that the IntoResponse
impl renders through the shared error template. NotFound renders the
dedicated not-found template. Io and Notify appear during server startup
(socket binding, file watcher) and render as opaque 500s if they ever surface
through a handler.
| Variant | Description |
|---|---|
BadRequest(String) |
400 Bad Request with a user-facing message. |
Internal(String) |
500 Internal Server Error; the wrapped detail is logged, never rendered. |
Io(Error) |
Filesystem or network I/O error (server bootstrap or request handling). |
NotFound |
404 Not Found; renders the not_found.html template. |
Notify(Error) |
File watcher error from the notify crate (server bootstrap). |
Implements Debug, Error, Display, From<Error>, IntoResponse.
struct ErrorTemplate
struct ErrorTemplateThe error.html page that Error renders for 400 and 500 responses.
| Field | Type | Description |
|---|---|---|
message |
String | The message shown to the user; never the internal error detail. |
status |
u16 | The HTTP status code shown on the page, such as 400 or 500. |
Implements Template, Display, FastWritable.
struct NotFoundTemplate
struct NotFoundTemplate;The not_found.html page that Error::NotFound renders with a 404 status.
Implements Template, Display, FastWritable.
fn render_error
fn render_error(status: StatusCode, message: String) -> ResponseRender the shared error template for a given status and user-facing message.
If the template fails to render, the body falls back to plain text such as 500 — error.
| Parameter | Type | Description |
|---|---|---|
status |
StatusCode | the HTTP status of the response, also shown on the page |
message |
String | the user-facing message shown on the page |
| returns | Response | An HTML response with the given status. |
const RELOAD_SOCKET_FILE
pub const RELOAD_SOCKET_FILE: &str = "web.sock";File name of the unix domain socket used for the web reload IPC channel.
fn reload_socket_path
pub fn reload_socket_path(gest_dir: Option<&Path>, data_dir: &Path) -> PathBufResolve the unix domain socket path used by the web server’s reload listener.
When gest_dir is provided (the project is in local mode with a .gest/ directory)
the socket lives at <gest_dir>/web.sock. Otherwise it lives next to the SQLite
database file at <data_dir>/web.sock. Both the server-side listener and the
CLI-side notifier resolve the same path through this helper.
| Parameter | Type | Description |
|---|---|---|
gest_dir |
Option<&Path> | the project’s .gest/ directory in local mode, or None |
data_dir |
&Path | the data directory that holds the SQLite database |
| returns | PathBuf | The path of the web.sock socket file. |
fn serve
pub async fn serve(
store: Arc<Db>,
project_id: crate::store::model::primitives::Id,
addr: SocketAddr,
gest_dir: Option<PathBuf>,
socket_path: Option<PathBuf>,
debounce_ms: u64,
csrf_key: CsrfKey,
cache_dir: PathBuf,
) -> Result<(), Error>Start the web server on the given address.
When gest_dir is provided, a file watcher monitors the .gest/
directory and sends SSE reload pings on changes (debounced).
When socket_path is provided (and the platform is unix), a unix domain socket
listener is bound there and forwards bare connection signals to the SSE reload
channel — letting CLI mutations wake browser tabs without polling the filesystem.
The git author (or $USER) is looked up once at startup and recorded as the author of notes
added through the dashboard. The server runs until the TCP listener stops.
| Parameter | Type | Description |
|---|---|---|
store |
Arc<Db> | the database the handlers read and write |
project_id |
crate::store::model::primitives::Id | the project whose tasks, artifacts and iterations the dashboard shows |
addr |
SocketAddr | the address and port the TCP listener binds |
gest_dir |
Option<PathBuf> | the .gest/ directory to watch for changes, or None for no file watcher |
socket_path |
Option<PathBuf> | where to bind the reload socket, or None for no socket; ignored off unix |
debounce_ms |
u64 | the least time, in milliseconds, between two reload pings from the file watcher |
csrf_key |
CsrfKey | the key that signs CSRF cookies |
cache_dir |
PathBuf | the cache directory that holds the avatar cache |
| returns | Result<(), Error> | Ok(()) when the server stops, or an Error if the database connection, the file watcher or the TCP listener fails. A reload socket that cannot be bound is logged as a warning, not an error. |
fn router
fn router(state: AppState, csrf_key: CsrfKey) -> RouterBuild the application router with all routes.
Every route passes through the CSRF, CSP nonce, security header and request log middleware, and
unmatched paths go to the not-found handler. A successful write then exports the database to .gest/.
| Parameter | Type | Description |
|---|---|---|
state |
AppState | the shared state given to every handler |
csrf_key |
CsrfKey | the key that the CSRF middleware signs and checks cookies with |
| returns | Router | The router, ready for axum::serve. |