aboutsummaryrefslogtreecommitdiff
path: root/lib/http.h
diff options
context:
space:
mode:
authorspl3g <spleefer6@yandex.ru>2025-03-21 14:37:04 +0300
committerspl3g <spleefer6@yandex.ru>2025-03-22 11:12:11 +0300
commit66dee85d1fbfe7fecdd37503389ad467c3ccfb81 (patch)
tree7cdd0c6a08b1b4abd37d1f4cd062090eaa4180a8 /lib/http.h
parent358f08897aca0aafeed993e91ef63edc00fd288f (diff)
Add global middleware support
Diffstat (limited to 'lib/http.h')
-rw-r--r--lib/http.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/http.h b/lib/http.h
index 2cfa9eb..0657095 100644
--- a/lib/http.h
+++ b/lib/http.h
@@ -101,13 +101,18 @@ struct handler_da {
size_t cap;
};
+typedef struct {
+ http_middleware *start;
+ http_middleware *end;
+} http_global_middleware;
+
struct server {
size_t sockfd;
struct sockaddr *addr;
arena *arena;
handler_da handlers;
context global_ctx;
- http_middleware *global_middleware;
+ http_global_middleware *global_middleware;
};
typedef enum {
@@ -163,8 +168,9 @@ void http_send_body(struct request req, const_string body);
int init_server(arena *arena, struct server *serv, char *addr, char *port);
int listen_and_serve(struct server *serv);
-handler *handle_path(struct server *serv, const_string method, const_string path, handler_func handler);
+handler *http_handle_path(struct server *serv, const_string method, const_string path, handler_func handler);
+void http_register_global_middleware(struct server *hand, http_middleware_func func);
void http_register_handler_middleware(arena *arena, handler *hand, http_middleware_func func);
#endif // HTTP_H_