web: std/web package: WebError, Handler and the request and response helpers (step 1 of #94) #575
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Step 1 of the epic #94 (WEB slice 2,
std/webcore): the packagestd/webwith its error type, its handler type and the helpers that turn astd/httpRequestandResponseinto the vocabulary the rest of the slice builds on. No middleware, noweb { }block and no test helper yet (steps 2 and 3 of #94).Source
WebError.std/web, no HTTP instd/html), D10 (a panic ends the process, so no 500 page for one).std/httpRequest,Response,Handler,HttpError(std/http/src/message.trb,server.trb).Design record point
WEB.md slice 2, first part; D13. Decided by the loop (details in the comment on #94):
std/webdeclarestype Handler = (request: Request) => Task<Result<Response, WebError>>withRequestandResponsetaken fromstd/http. It does not re-exportstd/http'sHandler; a program that needs both writesuse * as http from "std/http".WebErroris a capsule:status(): Status, a public message, a privatecause(): Error?; constructorsbadRequest,forbidden,notFound,payloadTooLarge,unprocessable,internal;From<DecodeError>(400) andFrom<HttpError>(400, the cause kept; the mapping is a table in the doc comment).WebError.response()renders the default error page of its status; theerrorshook of the application is step 2.extendonstd/http'sRequestandResponse:Request.decodedSegments()(percent-decoded, empty segments dropped;Request.segments()ofstd/httpstays as it is),Request.queryParameters()andqueryParameter(name)overString.formDecodedofstd/uri;Response.html(page)(200,text/html; charset=utf-8),Response.redirect(to: Link)(303),withStatus,withHeader.Response.jsonOfofstd/httpalready exists and is used as it is.RequestandResponseareshared types that own a stream, not values (WEB.md section 9 assumed values). The participles therefore answer a newResponsethat takes over the sameBody; the old binding is not read afterwards. The doc comment says so, a test holds it, and WEB.md section 3.4 gets a "Built" note saying where this departs from the record, like URI.md section 9a does.request.query<Value>()(needs the form-urlencodedDecoderthat #97 builds),request.form, cookies andwithCookie(#98),request.json(Response.jsonofstd/httpexists; the request side follows with forms).Acceptance criteria
std/web/project.trbandsrc/exist withWebError,Handlerand the helpers above, exported fromlib.trb; every public item has a doc comment with an example.std/web/tests/): the status of eachWebErrorconstructor and theFromconversions; the default error page per status;decodedSegmentson/orders/a%20b//7answers["orders", "a b", "7"];queryParameteron a repeated and on a missing name;Response.htmlsets status and content type;Response.redirectis 303 withLocation;withStatusandwithHeaderleave the headers and the body readable on the answered response. Handlers in the tests arefns answering aTaskthat the test file awaits at its top level (atestbody cannot wait yet, WEB.md F13).docs/standard-library/web.md, linked from the index;skills/regenerated (torb docs skill docs skills).Request/Responseabove.feat(std/web): add WebError and Handler,feat(std/web): add the request and response helpers.Dependencies
std/httpRequest/Response(onmain),std/uriLinkusers viastd/html(onmain).Middleware,Next,WebApp,web { }), #97, #98.Part of #94.
std/webcore (WEB slice 2) #94std/webcore (WEB slice 2) #94std/webcore (WEB slice 2) #94[loop:torbscript] claim implement by session:loop-torbscript-20261029 until 2026-10-29T14:35Z
[loop:torbscript] implement: PR #578 open, CI pending (commit messages, what the change touches and pdisc green; gates, bootstrap and tiers queued on the runners), review requested from argus, next: waiting (forge CI and merge gate). Local: 47 std/web tests pass, format and docs checks clean. Tokens: one implementer run (Sonnet 5.5), usage in the run record.