|
Pharos 0.7.23
Modern Web Framework & Web App Hosting Service.
|
Route dispatch for in-process dynamic-app request handling. More...
Go to the source code of this file.
Data Structures | |
| struct | NativeDynamicRouteMatch |
| Describes one matched route from the route fixture. More... | |
Functions | |
Dispatch helpers | |
| int | native_dynamic_dispatch_match (const char *route_fixture_path, const char *method, const char *path, NativeDynamicRouteMatch **match_out) |
| Matches a request path against the route fixture for an app. | |
| void | native_dynamic_dispatch_free_match (NativeDynamicRouteMatch *match) |
Frees a route match returned by native_dynamic_dispatch_match(). | |
| char * | native_dynamic_dispatch_response_file (const char *artifact_dir, const char *method, const char *path) |
| Resolves the response artifact file for a matched page route. | |
| char * | native_dynamic_dispatch_resolve_route_fixture (const char *artifact_dir, const char *app_id) |
| Resolves the route fixture path from the artifact directory. | |
| char * | native_dynamic_dispatch_extract_param (const char *pattern, const char *path, const char *param_name) |
| Returns the URL path parameter value extracted from a matched route. | |
Route dispatch for in-process dynamic-app request handling.
This module reads the app's route fixture JSON and matches an incoming request path against the declared routes. It supports both exact segment matches and parameterised segment patterns (e.g. /businesses/:business_slug/).
The dispatch layer also resolves the response artifact file for API-style routes that have pre-built static responses in the dispatch table.
Definition in file native_dynamic_dispatch.h.
| char * native_dynamic_dispatch_extract_param | ( | const char * | pattern, |
| const char * | path, | ||
| const char * | param_name ) |
Returns the URL path parameter value extracted from a matched route.
Given a route pattern like /businesses/:business_slug/ and a concrete path /businesses/foo-bar/, this returns "foo-bar".
| pattern | Route pattern from the fixture. |
| path | Concrete request path. |
| param_name | Name of the parameter segment (without the colon). |
Definition at line 518 of file native_dynamic_dispatch.c.
References count_segments(), dup_range(), get_segment(), and segment_length().
Referenced by handle_accept_invite_action_runtime(), handle_action_route(), handle_issue_business_invite_action_runtime(), handle_password_reset_complete_action_runtime(), native_dynamic_runtime_handle_request(), resolve_declared_page_params_json_runtime(), and resolve_invite_accept_page_params_json_runtime().
| void native_dynamic_dispatch_free_match | ( | NativeDynamicRouteMatch * | match | ) |
Frees a route match returned by native_dynamic_dispatch_match().
| match | Match record to free, or NULL. |
Definition at line 488 of file native_dynamic_dispatch.c.
References NativeDynamicRouteMatch::action_id, NativeDynamicRouteMatch::auth_gate, NativeDynamicRouteMatch::kind, NativeDynamicRouteMatch::layout_id, NativeDynamicRouteMatch::page_id, NativeDynamicRouteMatch::path, NativeDynamicRouteMatch::policy_gate, and NativeDynamicRouteMatch::route_id.
Referenced by native_dynamic_dispatch_match(), and native_dynamic_runtime_handle_request().
| int native_dynamic_dispatch_match | ( | const char * | route_fixture_path, |
| const char * | method, | ||
| const char * | path, | ||
| NativeDynamicRouteMatch ** | match_out ) |
Matches a request path against the route fixture for an app.
Reads route_fixture_path and walks the route list looking for a match. Parameterised segments (prefixed with : ) match any non-empty segment in the corresponding position.
| route_fixture_path | File-system path to the route fixture JSON. |
| method | HTTP method (GET, POST, etc.). |
| path | Normalised request path (query string already stripped). |
| match_out | Destination for the allocated match record. Caller must free with native_dynamic_dispatch_free_match(). |
Definition at line 365 of file native_dynamic_dispatch.c.
References NativeDynamicRouteMatch::action_id, NativeDynamicRouteMatch::auth_gate, NativeDynamicRouteMatch::kind, NativeDynamicRouteMatch::layout_id, native_dynamic_dispatch_free_match(), native_json_doc_free(), native_json_doc_load_file(), native_json_obj_get(), native_json_obj_get_array(), native_json_obj_get_string_dup(), NativeDynamicRouteMatch::page_id, NativeDynamicRouteMatch::path, pattern_matches(), NativeDynamicRouteMatch::policy_gate, NativeDynamicRouteMatch::route_id, route_pattern_specificity_score(), yyjson_arr_get(), yyjson_arr_size(), yyjson_doc_get_root(), and yyjson_get_str().
Referenced by native_dynamic_runtime_handle_request().
| char * native_dynamic_dispatch_resolve_route_fixture | ( | const char * | artifact_dir, |
| const char * | app_id ) |
Resolves the route fixture path from the artifact directory.
Reads the manifest from artifact_dir and returns the file-system path to the route fixture JSON.
| artifact_dir | App artifact directory. |
Definition at line 565 of file native_dynamic_dispatch.c.
References resolve_route_fixture_path().
Referenced by native_dynamic_runtime_handle_request().
| char * native_dynamic_dispatch_response_file | ( | const char * | artifact_dir, |
| const char * | method, | ||
| const char * | path ) |
Resolves the response artifact file for a matched page route.
Looks up the dispatch table in artifact_dir and returns the pre-built response file for routes whose paths are served as static responses. Returns NULL when no static response file exists for the route.
| artifact_dir | App artifact directory. |
| method | HTTP method. |
| path | Normalised request path. |
Definition at line 503 of file native_dynamic_dispatch.c.
References native_dispatch_response_file_for_request().
Referenced by native_dynamic_runtime_handle_request().