Pharos 0.7.23
Modern Web Framework & Web App Hosting Service.
Loading...
Searching...
No Matches
native_dispatch_table.c File Reference

Matches API request paths against the dispatch table and resolves the response artifact file to serve. More...

#include "native_dispatch_table.h"
#include "native_json_config.h"
#include "native_support.h"
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Macros

#define native_dispatch_strdup   strdup

Functions

int native_dispatch_route_pattern_matches (const char *pattern, const char *path)
 Tests whether a request path matches one dispatch-table route pattern.
char * native_dispatch_response_file_for_request (const char *root, const char *method, const char *path)
 Resolves the response artifact file for one request using the dispatch table.

Detailed Description

Matches API request paths against the dispatch table and resolves the response artifact file to serve.

Definition in file native_dispatch_table.c.

Macro Definition Documentation

◆ native_dispatch_strdup

#define native_dispatch_strdup   strdup

Definition at line 17 of file native_dispatch_table.c.

Referenced by native_dispatch_response_file_for_request().

Function Documentation

◆ native_dispatch_response_file_for_request()

char * native_dispatch_response_file_for_request ( const char * root,
const char * method,
const char * path )

Resolves the response artifact file for one request using the dispatch table.

Parameters
rootArtifact root directory containing dispatch metadata.
methodHTTP method for the request.
pathNormalized request path.
Returns
Newly allocated response file path, or NULL when no route matches.

Definition at line 47 of file native_dispatch_table.c.

References json_find_string_after(), native_dispatch_route_pattern_matches(), native_dispatch_strdup, path_join(), read_file_text(), starts_with(), and streq().

Referenced by native_dynamic_dispatch_response_file(), and native_serve_static_file().

◆ native_dispatch_route_pattern_matches()

int native_dispatch_route_pattern_matches ( const char * pattern,
const char * path )

Tests whether a request path matches one dispatch-table route pattern.

Parameters
patternDispatch-table route pattern.
pathNormalized request path to test.
Returns
Non-zero when the path matches the pattern, otherwise 0.

Definition at line 20 of file native_dispatch_table.c.

Referenced by native_dispatch_response_file_for_request().