Repository navigation
0.14.0
Access control with Spindle.Access, a route's own limits and policies under the app's names, and a time limit on handlers.
Upgrading
~meta:Meta.(empty |> add Meta.access Logs.Debug)→~access_log:Logs.Debug:Spindle.Metais gone, and a route's settings are labels.~meta:Meta.(empty |> add Compress.never ())→~compress:Compress.none.Meta.find Meta.summary info.meta→info.summary, anddoc,tagsandaccess_logalike.- A key of your own read by middleware → a dependency of the route, as
Spindle.add_headerfor a header one route needs. App.answered'saccess→access_log.~cors:(Cors.origins ~routes:api_only [ site ])on the application →~cors:(Cors.origins [ site ])on each API route, through a shared maker:let api_get = Spindle.get ~cors:site.Spindle.body_stream ~max:n ()→Spindle.body_stream ()on a route with~limits:(Route.Limits.make ~max_body:n ()), andSpindle.multipartalike.- A handler that runs longer than a minute → its own
~limits:(Route.Limits.make ~handler_timeout:...), or it is answered503 timed_out. - A server whose
max_bodyis above itsbody_budget→ amax_bodythe budget can hold, or a stream: a body read whole there is500, since none between the two could ever be held. - A connection loop of your own:
Body.source'swholeandparttake the route's limits as optional arguments,partlosing~max. - A test that sends a body read whole past
max_bodyis now413, as on a server.
New
Spindle.Access: a policy is a function of the caller, an action and the object;Access.can action resourcehands a route the object only once its policy allows the action, answering someone else's as a missing one.Access.requireandAccess.checkrefuse403 forbidden; every denial is onewarnline naming the policy, the action, the caller's id and the reason;Access.decideanswers what a policy decides, for a test.Route.infolists who may call a route, the OpenAPI document prints it asx-spindle-access, andAccess.unguarded routesnames the routes that read no check.Dep.attempt dhands overd's refusal as a value, so an MCP tool's dependency may refuse and its refusal is the tool'sisError.handler_timeout, 60 s unless given inServer.Limits.makeor a route'sRoute.Limits.make: past it the handler is cancelled with everything it started and answered503 timed_out; time spent waiting on its body is not counted.- A route's
~limitsgive its ownmax_body,body_timeout,min_body_rateandhandler_timeoutin place of the server's, by the same names. - A route's
~compressand~corsare its policies in place of the application's: one route can compress, or allow a site, under an application that does not.Compress.noneandCors.noneturn either off. Spindle.Test.app ~limitsreads every body as the server does.App.handle ?withinis how a connection loop of its own bounds a handler's time.
Fixed
- A route under
Compress.noneno longer saysVary: Accept-Encoding, since its answers do not vary by it. - A preflight is answered under the policy of the route that answers the method it asks for, so two routes at one path may allow different sites.