feat: allow matching regex routes

This commit is contained in:
Jef Roosens 2023-05-29 16:55:16 +02:00
parent dd0ba31506
commit 464753d627
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
5 changed files with 85 additions and 14 deletions

View file

@ -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;

View file

@ -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