App, Group, Operation. A group is a prefix and what holds under it, an operation
is one typed route declared there, and the verb methods are generic methods —
which Go 1.27 allows on a concrete type and still refuses on an interface. So In
and Out come from the handler and the caller writes no type arguments:
users := app.Group("/v1/users")
users.Post("/", api.Create)
mint := users.Group("/mint").With(middleware.Mint(gate))
mint.Post("/deposit", api.Deposit)
A Group is a CLOSED HANDLE: two unexported fields, and no method that hands back
the app, the parent or the fiber underneath. A subsystem given the group at its
own prefix cannot reach above it, so confinement is a property of the type
instead of a rule something has to police — which is what a host needs in order
to hand out a bounded surface and know what comes back.
That is bought by giving up the router interface, deliberately. Router and
OpTarget are gone, and with them the ability to implement a route table outside
this package: a decorator is no longer a router, a gate is middleware on a group,
and a bound is a path. The five package-level verb functions go the same way —
a registration is a method on the thing it registers into.
Raw carries what is not a typed operation: a stream, an upgrade, a probe, a
foreign subtree. It names its method, and it is the longer spelling because
opting out of the typed model is the exception and should read like one.
Co-authored-by: Hanzo Dev <[email protected]>
Static advertised no Accept-Ranges and answered every Range with the whole
file, so a caller that needed one had to leave Static behind and
re-implement file serving to get it.
One range per request: 206 with Content-Range for a span the file has, 416
for a span it does not, and the whole file for anything it declines --
absent header, an unknown unit, or a multi-range request, all of which RFC
9110 14.2 lets a server answer in full. If-Range is honoured, and a 304
still outranks a range because the client already holds the bytes.
Content is the same answer over an already-open representation, exported
because Static cannot be the only way to reach it: a handler that
negotiates a precompressed sibling, or names its own cache class, needs the
conditional and the range without Static's content-type guess. The caller
owns Content-Type there -- a .br beside main.css is still text/css, and
guessing from the stored name would call it brotli.
A source that cannot seek is served whole, so no fs.FS loses an answer it
used to give. Measured on both fixtures: embed.FS and os.DirFS both seek,
and embed carries no modification time, so If-Range can only match on the
directory one.