#ifndef CORE_ROUTER_H #define CORE_ROUTER_H #include #define ENDPOINTS_MAX_COUNT 128 typedef enum { ENDPOINT_ARG_TYPE_INT, ENDPOINT_ARG_TYPE_STR } endpoint_arg_type_e; typedef enum { HTTP_METHOD_GET = (1 << 0), HTTP_METHOD_POST = (1 << 1), HTTP_METHOD_PUT = (1 << 2), HTTP_METHOD_DELETE = (1 << 3), HTTP_METHOD_OPTIONS = (1 << 4) } http_method_e; typedef struct { endpoint_arg_type_e type; union { int v_int; const char *v_str; } value; } endpoint_args_t; typedef void (*endpoint_func_f)(struct mg_connection *c, endpoint_args_t *args, struct http_message *hm); typedef struct { const char *full_route; char **route; char *route_keeper; int method; int options; endpoint_func_f func; int trailing_slash; int args_count; endpoint_args_t *args; int possible_route; int args_found; } endpoint_t; void router_init(); endpoint_t* router_register_endpoint(const char *route, int method, endpoint_func_f func); endpoint_t* router_find_endpoint(const char *uri_str, size_t uri_len, struct mg_str *method_str); void router_free(); #endif /* CORE_ROUTER_H */