Goals
Components on the server — design
Status: implemented are markup as HTML, components of the server, their results,
Responsegoing up,Content<T>, component values with a result, decorators with guards, wrappers that take the body and the request context, routes, androoklang/server; the server of the site,site/server/main.rk, is written with them, and the guide has a section on them. The decisions are collected at the end of the document, together with what is not decided yet. Server markup, components androoklang/serverremain experimental in 1.x and may change between releases.
This document builds on components.md: components, decorators, context, components as values. It describes only what is different on the server.
- A backend is a tree of components. Middleware, a router, access checks and pages are components and decorators, as the views of the browser are. A request goes down the tree, and the value the tree gives becomes the response.
- Markup on the server is a string of HTML. The same tags, attributes and checks as in the
browser, but
<div>gives a string, with no DOM and no updates. - Not only markup. A component of the server returns any value: HTML, a
Response, data that becomes JSON. So the tree serves pages and an API alike. - The language gives the means, not a framework. Routing, sessions and access are written in Rook with these means, as a library; the language has none of them built in.
- Types along the whole way, from the
Requestto the response, and readable JavaScript that runs in Node, Bun, Deno and Workers.