Documentation
¶
Overview ¶
Package static is the edge static-asset handler (ADR-0120, F82): it serves a Bucket-prefix static site directly through the FEAT-0006 edge — index resolution, content-types, a weak (ModTime,Size) ETag + conditional GET (304), HTTP Range (206), an optional SPA fallback, and a pinned three-tier Cache-Control — with no function code and no activator hop. The bytes are the same per-namespace Bucket view the S3 frontend serves (ADR-0080), read over the blob.Bucket port.
Security (ADR-0120 B1): the traversal defense is OWNED here, not inherited from the blob driver. It path.Cleans the (already percent-decoded) request remainder, rejects any `..`-containing path, and asserts the resolved object key has the declared Prefix BEFORE any blob Get — no read can escape the prefix / bucket / namespace.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BucketResolver ¶
BucketResolver resolves a (namespace, bucket) to its per-namespace blob view (the same s3BucketFor the S3 frontend uses, ADR-0080). ok=false ⇒ the Bucket is missing / cross-namespace.
type Deps ¶
type Deps struct {
Buckets BucketResolver
Logger *slog.Logger
}
Deps are the Handler's dependencies.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves a Bucket-prefix static site over the edge (F82). It resolves it, it does not proxy — there is no function to wake.
func (*Handler) Serve ¶
func (h *Handler) Serve(w http.ResponseWriter, r *http.Request, ns v1.NamespaceName, back *v1.StaticBackend, remainder string)
Serve writes the object at <back.Prefix><cleaned-remainder> in back.Bucket. remainder is the function-relative path (the matched Route prefix already stripped), always starting "/", and already percent-decoded (it is cut from r.URL.Path, which net/http decodes), so it is not decoded again. It owns the 405 (non-GET/HEAD), the traversal defense (B1), the weak (ModTime,Size) ETag validator (M1), the three-tier Cache-Control (M3), index resolution and the SPA fallback; the stdlib http.ServeContent handles Last-Modified / If-Modified-Since / If-Range / If-None-Match → 304 / Range → 206.