Capy-Bearer Documentation

INIT

Capy

function INIT()
function INIT(request : any)

Bearer calls INIT when it loads the unit into a workspace, before its first dispatch. A unit first needed later in a request initializes then, not at request start. Loading through #import or unit_load() can trigger INIT without rendering anything.

Use INIT to initialize unit variables. It runs once per unit per workspace. Ordinary requests get separate workspaces, so this is not server startup initialization.

The handler has an implicit request binding of type any. The explicit declaration function INIT(request : any) receives the same shared request value.

For CSS or JavaScript shared by component output, use ONCE. That hook waits until the first render or component invocation. When both hooks run, the order is INIT, ONCE, then the selected handler.

print(request.method, "\n")

Output

GET