aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorspl3g <spleefer6@yandex.ru>2025-03-22 21:41:16 +0300
committerspl3g <spleefer6@yandex.ru>2025-03-22 21:41:16 +0300
commit62454373db4cd2add82ded0cf7b21f7d69ade597 (patch)
tree1627133fe4567e9a3abb707af5e7289353410d5f /main.c
parentef5f52fb739c9f0d71c579f08363ef0dfd5c227d (diff)
Reorganize the lib
Diffstat (limited to 'main.c')
-rw-r--r--main.c34
1 files changed, 0 insertions, 34 deletions
diff --git a/main.c b/main.c
deleted file mode 100644
index 019597b..0000000
--- a/main.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "lib/const_strings.h"
-#include "lib/http.h"
-
-void success(http_request req) {
- req.resp->code = OK;
- req.resp->body = CS("Hello world!\n");
- http_send(req);
-}
-
-void logging_func(http_middleware *self, http_request req) {
- http_run_next(self, req);
- http_log(HTTP_INFO, CS_FMT" "CS_FMT": %ld\n", CS_ARG(req.method), CS_ARG(req.path), req.resp->code);
-}
-
-void whatever(http_middleware *self, http_request req) {
- http_log(HTTP_INFO, "Whatever");
- http_run_next(self, req);
-}
-
-int main() {
- arena arena = {0};
- http_server serv = {0};
- if (init_server(&arena, &serv, "127.0.0.1", "6969") != 0) {
- return 1;
- }
-
- http_register_global_middleware(&serv, logging_func);
- http_handler *success_handler = http_handle_path(&serv, CS("GET"), CS("/"), success);
- http_register_handler_middleware(&arena, success_handler, whatever);
-
- listen_and_serve(&serv);
-
- return 0;
-}