Files
probo/pkg/brand/brand.go
Ludovic Vielle dbfd191bc5 Add cache control to Files API static assets
Brand assets served at /api/files/v1/static had no cache headers.
Introduce brand.Assets to own the embedded filesystem, content-hash
ETags, and HTTP serving. Responses now carry Cache-Control and ETag
so clients can cache and revalidate; stable email URLs stay
revalidatable (max-age=3600, no immutable).

Replace hardcoded Default*Path constants with StaticPathPrefix,
logical filename constants, and StaticPath(). NewAssets validates
required assets at startup so a rename fails fast instead of 404ing
in sent emails. The files handler keeps routing and 404 rendering;
ServeAssets sets cache headers and serves the file.

Signed-off-by: Ludovic Vielle <ludovic@probo.com>
2026-06-12 17:24:00 +02:00

20 lines
529 B
Go

package brand
import (
"embed"
)
//go:embed assets
var staticAssets embed.FS
// Logical brand assets. These filenames must exist under assets/; NewAssets
// verifies their presence at startup so a rename or removal fails fast instead
// of silently producing a 404 in the consumers (e.g. emails).
const (
PoweredByLogo = "probo-gray-small.png"
SenderCompanyLogo = "probo.png"
)
// requiredAssets are validated to exist whenever an Assets is constructed.
var requiredAssets = []string{PoweredByLogo, SenderCompanyLogo}