Repository navigation
0.9.0
An API consistency pass before 1.0: one rule for errors, typed options where strings and runtime raises were, and fixes for requests that failed on ordinary input.
Upgrading
Apps and servers
- An app is made, then started:
App.startanswers anApp.instance, whichServer.runandTest.calltake.~resourcesand~keysmove fromApp.maketoApp.start. - Server limits are one value:
~limits:(Spindle.Server.Limits.make ~max_body:… ())replaces 13 arguments onserve,Server.runandserve_on. ~codes→~refusesonApp.make,Spindle.serveandTest.app.~not_foundis a dependency, written like a handler:Spindle.Dep.return (Ok page).Spindle.client→Spindle.client_ip;Path.str→Path.string.
Requests and errors
Body.read,Multipart.nextandMultipart.readfail with aRefusal.t, so a handler'slet*needs no conversion.Body.refusalandMultipart.refusalare gone.Dep.of_body ~need:(Raw { content_types })→Dep.of_body ~content_types:[ … ].- WebSocket errors are open tags:
`Socket (`Closed c),`Lost,`Undecodable(wasUnreadable),`Unwritable. A socket handler may end with its own errors (closed1011).
Cookies and sessions
- Keys are given where the app starts:
Spindle.serve ~keys.Cookie.signedandCookie.encryptedtake no ring. - A session is a dependency:
let+ session = session, thenSession.get,put,rotate,destroy, each answering aRefusal.t. Session.create ~storetakes aSession.store Dep.t;Session.sweepis gone (sessions sweep themselves).Spindle.Cookie.encodedis gone: a plain cookie holds any text now.
Modules
- CORS:
Cors.make ~credentials:true (Origins [ … ])→Cors.origins ~credentials:true [ … ];Cors.make Any→Cors.any (). - OpenAPI:
Openapi.docs→Openapi.routes;Openapi.routes(theresultone) →Openapi.make. Cache.forever ~under:[ "/assets/" ]→~under:Spindle.Path.[ s "assets" ].Static.loadandStatic.directorytake no~immutable; keep hashed assets withCache.forever.Health.checkreads what it checks as a route does;Pool.check dbtakes the pool's dependency.spindle.http's wire internals (Head,Framing,Write, the socket runner) move underSpindle_http.Private. The version type isSpindle_http.Version.t; an HTTP date is written withDate.to_string.Spindle_clienthas one response type,'body response;answeris gone.
New
Spindle.Syntaxhaslet*besidelet+andand+.serveandSpindle_client.runtake only the Eio capabilities they use;envstill works.?guardonHealth.routes,Openapi.routesandOpenapi.make.- Client errors are open tags, so a call and a database statement join under one
let*.
Fixed
- A refusal after a session moved no longer signs the user out: what a handler sets goes with its answer, a refusal included.
- A cookie set from request text (
"Kim Li") no longer answers500: plain cookie values are percent-encoded. - A stale or broken plain cookie no longer answers
400on every page: it reads as absent. - Counting a metric no longer fails its request: a bad count is left out and logged once.
- Keys given as a resource now seal cookies, where setting one answered
500.