http
This module provides a basic HTTP server for building web applications.
| Name | Summary |
|---|---|
| handle | Registers a handler for the given path pattern. |
| listen | Starts the HTTP server. |
| static | Serves static files from a directory at the given route prefix. |
fn handle(path, handler) -> null
Registers a handler for the given path pattern. Supports path parameters like /users/:id
Parameters
| path | URL pattern (e.g. '/users/:id') |
| handler | Function(req, res) or {GET: fn, POST: fn, ...} |
null
fn listen(addr) -> null
Starts the HTTP server.
Parameters
| addr | Address to listen on (e.g. ':8080') |
null
fn static(route, directory) -> null
Serves static files from a directory at the given route prefix.
Parameters
| route | URL prefix (e.g. '/static') |
| directory | Local directory path (e.g. './public') |
null