From 25303ac1eed446359e79239d040551bfbfaaeda6 Mon Sep 17 00:00:00 2001 From: pedrofnseca Date: Mon, 28 Aug 2023 22:33:53 -0300 Subject: [PATCH] feat: router && logger --- bin/handler.o | Bin 0 -> 5568 bytes bin/main | Bin 17136 -> 21992 bytes bin/main.o | Bin 3768 -> 13008 bytes src/handler.h | 25 +++++++++++++++++++++++++ src/logger.h | 20 ++++++++++++++++++++ src/main.c | 23 ++++++++++++++++++++--- 6 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 bin/handler.o create mode 100644 src/handler.h create mode 100644 src/logger.h diff --git a/bin/handler.o b/bin/handler.o new file mode 100644 index 0000000000000000000000000000000000000000..e776d6e14546cceccdbeb45563edb71a5da17e2a GIT binary patch literal 5568 zcmbtYYm6IL6}~g}ti9`fW<$DZ0_%j(l&ZF~tJRXG-LQ%4#@l4mCA*6#1v%sK_yP9V z%p>epElpL5PlW*UYt_$(?yb*EA+cW5?N+BvHoZM?-zyoo9R42iW@~ANt2?zI`+Q z+^wa2`{{S`?cnWvd-aWcd-3|2cJ9iV_TtO=OF58pw}Iczw}1I(bkDbMp!kaDzn*XZ zj^Ny8{<)_&SrEH|s&^0PFRgBZ<=fZZ;9kPJox26trVMr|ck5TLCUwRPrp3{10GkhD z6Q&nJLIV5I-`{l%m==$rq(wO!jB6r@rVCi><67N7HWW2#jt?$eimaobFc`*ueW{Ch<`rzDQz0 zh(8cwZ2AWH>Klx^#!g@5QoJ7+i%;-5*r;-;zu)J&^W&}!OEnNHbMZ4!_aT-@98W}s zA&|iq#-WxGmN*c{UesWb;bRB12NMq@7RL1nDE(eQ_QOu;OKTtB3(CZU#si7Ndl$wZ z+N*&_Y#j6t?S=H<8b{XypclUVGitPfG3_J6Sa+qO&Rrc4hKA*1{`rZgpz?7jGcGH@ zF|+$|uHb=D@m4l+jioI4Md%n{n**+C+CPVfkimAr*9deb`Er5SAzho)M+_9vN;Etp zZz9GD>lX!pa>D4>5A8OFpEvsS!@G^a!05kV#Nv+{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#DN2dO9hq6%=65~d2u8JBiZxjo1gdI zym@24zxcw1l%@$LP0WjJiBTc$=eEZSa=0K4i$mhifunydSGVp}Klp8M>-vN0R``4M zqbwR!x4!=s`Iq>*`)$?kblg+=CD-fJC&gEQWrZe#X3*eqe8uTxOwe+DC~299MQ&P( zqE*I9ZA|IKZV)>5 zxu)&dUfTlE^sLso_1T%?%(Px?>cxiXZ#Y)Va~(JIi=lJ1?bM5bS?kz7DE+{+E*IB4 zH?Xb1^@@G~hUgV3td8loSlxCVP*{zaEMSXQM5*O=?b4cE_uPi#+m=~swu4q!D|xmb z6wS4Eu_AoWD&dw4>))Eo41hU#iHnuW8U3l{TId8J?Y>wJrC5IN^l4*i`Xs?{%6O>; z;lX20N@i0l5PV6YS7I{l|xum0;nSdv+AT9E{Y!OI{{ylKGw+dn8;n+I)o?!&c<1V68 zkyW}D20j@aB91o-bN%39L`Mn7Gk7G1^NtXUXMImuae0sMW#!nND_OcI>T#n&5FRx=(!ATV76}(RJ1qFYGB&gXBGS{lKH&Ud3Dlbjl}Cj82&~Vx+UbyG z8$J_;1FhSD76+{xS~QYO2ad|Hf{8OG9COehkU*qZh;2eKNzQS zU{Q?22r1W5cqAol^pkW||aU`g}e zr1{sSSM;BNUsrYh>l9PnC;w-jP$p!N`GFH%9O*OdL3-`>OjbMnXfjuZPa{|uBo zj@$jDUIM!$Vg2Ag z1N$?cG&j0TVNjqPZTKLJlj;w#q*Tq){p0@>jD@7;ZwRm?f1MWkqx9N-ss8@}a;sBt diff --git a/src/handler.h b/src/handler.h new file mode 100644 index 0000000..582eaa4 --- /dev/null +++ b/src/handler.h @@ -0,0 +1,25 @@ +#include +#include +#include +#include "logger.h" + +enum MHD_Result default_handler(void *cls, struct MHD_Connection *connection, const char *url, + const char *method, const char *version, const char *upload_data, + size_t *upload_data_size, void **con_cls) { + struct MHD_Response *response; + char *url_str = (char *)url; + char *method_str = (char *)method; + int ret; + + log_api(url_str, method_str); + + response = MHD_create_response_from_buffer(strlen(url_str), (void *)url_str, MHD_RESPMEM_PERSISTENT); + + if (!response) + return MHD_NO; + + ret = MHD_queue_response(connection, MHD_HTTP_OK, response); + MHD_destroy_response(response); + + return ret; +} \ No newline at end of file diff --git a/src/logger.h b/src/logger.h new file mode 100644 index 0000000..7e78a1e --- /dev/null +++ b/src/logger.h @@ -0,0 +1,20 @@ +#include +#include + +void log_api(const char *url, const char *method, const char *status_code) { + char *color; + + if (strcmp(method, "GET") == 0) { + color = "\033[0;32m"; + } else if (strcmp(method, "POST") == 0) { + color = "\033[0;33m"; + } else if (strcmp(method, "PUT") == 0) { + color = "\033[0;34m"; + } else if (strcmp(method, "DELETE") == 0) { + color = "\033[0;35m"; + } else { + color = "\033[0;36m"; + } + + printf("%s[%s] %s -> %s\n", color, method, url); +} \ No newline at end of file diff --git a/src/main.c b/src/main.c index ffd55e6..4d61484 100644 --- a/src/main.c +++ b/src/main.c @@ -1,7 +1,24 @@ #include +#include #include +#include "handler.h" -int main(int argc, char *argv[]) { - printf("Hello, Wolrd!\n"); - return 0; +#define PORT 8080 +#define color_green "\033[0;32m" + +int main() { + printf("%sStart server on port %d\n", color_green, PORT); + + struct MHD_Daemon *daemon; + + daemon = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION, PORT, NULL, NULL, + &default_handler, NULL, MHD_OPTION_END); + if (!daemon) + return 1; + + getchar(); + + MHD_stop_daemon(daemon); + + return 0; }