Documentation
¶
Overview ¶
Package lodge serves maild as lodge's mail app on its app socket (docs/specs/lodge-app.md, ADR-0041): /health, the /api WebSocket as caller session, and /content/ for reader pages, parts and whole messages, which lodge-content serves to the reader's frame and to downloads.
Index ¶
Constants ¶
const ( MaxPages = 64 MaxPageBytes = 64 << 20 )
Limits on the reader pages kept for the content route; past either, the least recently kept page goes.
const ( PagePolicy = "default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:; " + "base-uri 'none'; form-action 'none'; sandbox allow-popups allow-popups-to-escape-sandbox" PartPolicy = "default-src 'none'; img-src data:; style-src 'unsafe-inline'; sandbox" )
The policies maild sends beside lodge's on content responses. A reader page may open the tabs its links ask for (the manifest's contentLinks); neither runs scripts or loads anything but data: URLs.
const ID = "mail"
ID is the mail app's id in lodge: its socket's name and URL segment.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Blobs ¶
type Blobs interface {
Open(id string) (io.ReadCloser, error)
}
Blobs opens a stored message by its blob ID (blob.Store).
type Content ¶
type Content struct {
// contains filtered or unexported fields
}
Content is what maild serves under /content/: reader pages kept in memory, and files of the parts cache and stored messages named by a MAC under a key drawn at start, so content paths are unguessable and end with the process.
func NewContent ¶
func NewContent(parts *render.PartsCache, blobs Blobs) (*Content, error)
NewContent serves parts from parts and messages' sources from blobs.
func (*Content) KeepPage ¶
KeepPage keeps a reader page and returns its content path, r/<token>.html, or "" for a page larger than MaxPageBytes.
func (*Content) PartPath ¶
PartPath is the content path of rel, a path in the parts cache: p/<mac>/<rel with each segment percent-encoded>.
func (*Content) ServeHTTP ¶
func (c *Content) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP serves GET and HEAD /content/<content path>. lodge has checked the caller; the socket's mux sends only caller content here.
func (*Content) SourcePath ¶
SourcePath is the content path of a stored message, the blob blobID, saved as name: m/<mac>/<blobID>/<name percent-encoded>. The MAC covers the name too, so a path names one file name.
type Options ¶
type Options struct {
// Ctx bounds the agents' connections to maild, which outlive the
// request that opened their MCP session, and the MCP sessions' janitor:
// maild's own context.
Ctx context.Context
// Version is maild's, for /health.
Version string
// RPC and Router serve /api, as the private socket does.
RPC *rpcserver.Server
Router *api.Router
// Content serves /content/.
Content *Content
Log *slog.Logger
// Now is the MCP tools' clock; nil is time.Now.
Now func() time.Time
}
Options are what maild's lodge socket serves.