core-legacy/include/router.h

53 lines
895 B
C
Raw Normal View History

2020-05-05 09:42:02 +00:00
#ifndef CORE_ROUTER_H
#define CORE_ROUTER_H
#include <mongoose.h>
#define ENDPOINTS_MAX_COUNT 16
typedef enum
{
ENDPOINT_ARG_TYPE_INT,
ENDPOINT_ARG_TYPE_STR
} endpoint_arg_type_e;
typedef struct
{
endpoint_arg_type_e type;
union
{
int v_int;
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
{
char **route;
char *route_keeper;
int methods;
endpoint_func_f func;
int args_count;
endpoint_args_t *args;
int possible_route;
int args_found;
} endpoint_t;
void
router_init();
void
router_register_endpoint(const char *route, int methods, endpoint_func_f func);
endpoint_t*
router_find_endpoint(const char *uri_str, size_t uri_len, struct mg_str *method);
void
router_free();
#endif /* CORE_ROUTER_H */