Mercurial
view mrjunejune/main.c @ 73:ede391ac83c8
[MrJuneJune] My own websites.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Wed, 31 Dec 2025 09:07:29 -0800 |
| parents | 4532ce6d9eb8 |
| children | c348ac875294 |
line wrap: on
line source
#include "seobeo/seobeo.h" volatile sig_atomic_t stop_server = 0; void handle_sigint(int sig) { printf("Failed\n"); stop_server = 1; } Seobeo_Request_Entry* GetUser(Seobeo_Request_Entry *req, Dowa_Arena *arena) { void *id_kv = Dowa_HashMap_Get_Ptr(req, ":id"); const char *user_id = id_kv ? ((Seobeo_Request_Entry*)id_kv)->value : "unknown"; Seobeo_Request_Entry *resp = NULL; char *body = Dowa_Arena_Allocate(arena, 256); snprintf(body, 256, "{\"id\":\"%s\",\"name\":\"John Doe\"}", user_id); Dowa_HashMap_Push_Arena(resp, "body", body, arena); return resp; } int main(void) { Seobeo_Router_Init(); Seobeo_Router_Register("GET", "/v1/users/:id", GetUser); Seobeo_Web_Server_Start("mrjunejune/pages", "6969", SEOBEO_MODE_EDGE, 2); }