feat: allow matching regex routes
This commit is contained in:
parent
dd0ba31506
commit
464753d627
5 changed files with 85 additions and 14 deletions
|
|
@ -1,12 +1,14 @@
|
|||
#ifndef HTTP
|
||||
#define HTTP
|
||||
|
||||
#include <regex.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "picohttpparser.h"
|
||||
|
||||
#define HTTP_MAX_ALLOWED_HEADERS 16
|
||||
#define HTTP_MAX_REGEX_GROUPS 4
|
||||
|
||||
extern const char *http_response_type_names[5][32];
|
||||
extern const char *http_header_names[];
|
||||
|
|
@ -33,6 +35,7 @@ typedef struct http_request {
|
|||
size_t path_len;
|
||||
const char *query;
|
||||
size_t query_len;
|
||||
regmatch_t regex_groups[HTTP_MAX_REGEX_GROUPS];
|
||||
struct phr_header headers[HTTP_MAX_ALLOWED_HEADERS];
|
||||
} http_request;
|
||||
|
||||
|
|
|
|||
|
|
@ -105,4 +105,6 @@ void http_loop_res_add_header(http_loop_ctx *ctx, http_header type,
|
|||
*/
|
||||
event_loop *http_loop_init(http_loop_gctx *gctx);
|
||||
|
||||
void http_loop_run(event_loop *el, int port);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue