Children: Content<T>

Components on the server — design

Status: implemented are markup as HTML, components of the server, their results, Response going up, Content<T>, component values with a result, decorators with guards, wrappers that take the body and the request context, routes, and rooklang/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 and rooklang/server remain 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 component that wraps others, a middleware, decides whether they run at all. So the children of a component of the server are lazy: they are rendered only when the component asks for them.

comp Logger<T>(children Content<T>) T {
    const started = Date.now()
    defer console.log(`${@session.url.pathname}: ${Date.now() - started} ms`)
    return await children()
}

Markdown source on GitHub