#ifndef CORE_ENDPOINT_H #define CORE_ENDPOINT_H #include 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; const char *v_str; } value; } endpoint_args_t; typedef struct { int status_code; const char *content_type; size_t content_length; const char *content; int alloced_content; } endpoint_response_t; typedef void (*endpoint_func_f)(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response); 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 endpoint_func_index(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response); void endpoint_func_not_found(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response); void endpoint_response_text(endpoint_response_t *response, int status_code, const char *content, int content_length); void endpoint_response_json(endpoint_response_t *response, int status_code, const cJSON *json_root); #endif /* CORE_ENDPOINT_H */