|
cwist
Modern C web framework with libttak runtime
|
Private wiring between app.c and the asset registry (assets.c). More...


Go to the source code of this file.
Classes | |
| struct | cwist_asset_match |
Typedefs | |
| typedef struct cwist_asset_match | cwist_asset_match |
Functions | |
| bool | cwist_assets_match (cwist_app *app, const cwist_http_request *req, cwist_asset_match *out) |
| Match an HTTP request to a registered asset. | |
| void | cwist_assets_respond (cwist_http_request *req, cwist_http_response *res, const cwist_asset_match *match) |
| Fill a response for a matched asset. | |
| int | cwist_assets_clone (void **dst, const void *src) |
| Deep-copy a registry (used when an app is cloned). | |
| void | cwist_assets_destroy (void *registry) |
Private wiring between app.c and the asset registry (assets.c).
Definition in file assets_internal.h.
A request resolved to an asset, and whether it used the hashed URL.
Deep-copy a registry (used when an app is cloned).
Deep-copy a registry for a detached sub-app. 0 on success (NULL copies to NULL).
Copies the prefix and every asset, preserving newest-first order. On failure *dst stays NULL and no partial registry is left behind.
| dst | Receives the new registry; set to NULL first. |
| src | Registry to copy; may be NULL, which is treated as empty. |
Definition at line 514 of file assets.c.
References ASSET_HASH_HEX, cap, cwist_alloc(), cwist_assets_destroy(), cwist_free(), cwist_strdup(), and head.
Release a registry and every asset in it. NULL is ignored.
Free a registry and every asset in it. No-op for NULL.
Definition at line 570 of file assets.c.
References cap, and cwist_free().
Referenced by cwist_app_destroy(), and cwist_assets_clone().
| bool cwist_assets_match | ( | cwist_app * | app, |
| const cwist_http_request * | req, | ||
| cwist_asset_match * | out | ||
| ) |
Match an HTTP request to a registered asset.
Resolve a GET/HEAD request path to a registered asset.
Only GET and HEAD requests under the registry prefix are considered. A request for a hashed (immutable) URL takes precedence over a logical name.
| app | App instance; must not be NULL. |
| req | Request to match; path must be present. |
| out | Filled with the matched asset and its immutability flag on match. |
Definition at line 410 of file assets.c.
References cwist_asset_match::asset, cwist_app::assets, cap, CWIST_HTTP_GET, CWIST_HTTP_HEAD, cwist_sstring::data, cwist_asset_match::immutable, cwist_http_request::method, and cwist_http_request::path.
| void cwist_assets_respond | ( | cwist_http_request * | req, |
| cwist_http_response * | res, | ||
| const cwist_asset_match * | match | ||
| ) |
Fill a response for a matched asset.
Fill res for a matched asset (200, or 304 on a matching If-None-Match).
Always sets ETag and Cache-Control; honors If-None-Match with 304 and an empty body. The body points directly at the asset data, which stays alive until the app is destroyed.
| req | Request being answered. |
| res | Response to fill. |
| match | Match from cwist_assets_match(); if NULL or without an asset, the response status is set to 500. |
Definition at line 475 of file assets.c.
References cwist_http_response::body, cap, CWIST_ASSET_IMMUTABLE_CACHE, cwist_error_dispose(), cwist_http_header_get(), CWIST_HTTP_INTERNAL_ERROR, CWIST_HTTP_NOT_MODIFIED, CWIST_HTTP_OK, cwist_http_response_set_body_ptr(), cwist_sstring_assign(), cwist_http_request::headers, and cwist_http_response::status_code.