feat(std/web): add WebError, Handler and the request and response helpers #578
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/575-std-web"
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?
Closes #575
Task: implement
std/webstep 1 of epic #94 (issue #575):WebError,Handlerand the request and response helpers.What
std/webpackage:Handler((Request) => Task<Result<Response, WebError>>, a type of its own beside theHandlerofstd/http),WebError(capsule over status, public message and private cause; constructorsbadRequest,forbidden,notFound,payloadTooLarge,unprocessable,internal; default HTML page viaresponse();From<DecodeError>andFrom<HttpError>so?works).Request.decodedSegments()(Result<List<String>, WebError>),queryParameters(),queryParameter(name).Response.html,Response.redirect(303),withStatus,withHeader.docs/standard-library/web.md, index,docs/design/WEB.md(built markers), regeneratedskills/.Decisions / departures from WEB.md
Request/Response/Bodyaresharedtypes owning a one-shot stream, so the participles build a newResponsethat takes over the body.decodedSegmentsfails with a 400 for a segment that is not UTF-8;Request.segmentsofstd/httpstays as it is.From<HttpError>: 413 for a body over its limit, 400 for other request-caused failures, 500 for network failures.Test:
torb test std/web(47 passed, 0 failed),torb format --check std/web,torb docs check|declarations --check|index --check|source|skill --check,tools/check-commits.sh origin/main HEAD. Bootstrap and gates run in forge CI.std/webpackage:WebError,Handlerand the request and response helpers (step 1 of #94) #575Checklist for
d1ff5dd:Non-blocking: