11#if DETWS_ENABLE_SPA_ROUTER
15bool detws_spa_has_extension(
const char *path)
20 const char *slash = strrchr(path,
'/');
21 const char *seg = slash ? slash + 1 : path;
22 const char *dot = strrchr(seg,
'.');
23 return dot && dot != seg && dot[1] !=
'\0';
26DetwsSpaAction detws_spa_route(
const char *path,
const char *api_prefix)
28 if (!path || path[0] ==
'\0' || (path[0] ==
'/' && path[1] ==
'\0'))
29 return DetwsSpaAction::DETWS_SPA_SERVE_SHELL;
31 if (api_prefix && api_prefix[0])
34 if (strncmp(path, api_prefix, pl) == 0)
35 return DetwsSpaAction::DETWS_SPA_PASSTHROUGH;
38 return detws_spa_has_extension(path) ? DetwsSpaAction::DETWS_SPA_SERVE_FILE : DetwsSpaAction::DETWS_SPA_SERVE_SHELL;
#define MAX_PATH_LEN
Maximum URL path length (including leading /).
Single-page-app micro-routing decision (DETWS_ENABLE_SPA_ROUTER).