Skip to contents

freshwater installs a per-request execution context that allows current_path(), csrf_token(), and template() helpers to access the active HTTP request. The context itself is stored in freshwater's internal state and is set/unset with each request. Context-dependent helpers are only valid when handling an active request. Moreover, requests are only active during synchronous execution.

Context is created automatically when api_freshwater(), api_csrf(), or api_error_pages() is installed.

Method spoofing is applied during the before-request phase by rewriting REQUEST_METHOD when a hidden _method field is present.

Lifecycle

The context exists only during an active HTTP request. Calling context-dependent helpers outside a request will raise a freshwater_context_missing error.