cweb.h reference

Module <cweb/cweb.h> — main entry

Via #include <cweb/cweb.h> you pull in the core modules Server, Routing, HTTP, Autofree, Logger, Fileserver, Template, Fetch, Speedbench, and Cwagger in one step.

Macros

REGISTER_FRONTEND_ASSET(func)

  • Purpose: Registers a function void func(void) that runs once at startup (typical: global styles/scripts or asset preprocessing). Uses a constructor attribute — the function is registered automatically before main.
  • Parameters: func — pointer to a function with no parameters/return value.
  • Notes: Requires GCC/Clang with support for __attribute__((constructor)).

Functions

void cweb_register_frontend_asset_function(void (*func)(void))

  • Purpose: Adds a callback to an internal list; it can be invoked in batch later.
  • Parameters: func — function executed when cweb_call_all_frontend_asset_functions runs.
  • Return: none.

void cweb_call_all_frontend_asset_functions(void)

  • Purpose: Calls all previously registered frontend asset functions in registration order (useful before cweb_run_server when preparing assets).
  • Parameters: none.
  • Return: none.
  • Notes: In a starter project typically called right before starting the server.

See also