commit ea6fb5fef87b339b9150ec6959dbfe78edabfd2f
parent 60c158311b7d1397269c7c6baa025b64c60000c7
Author: Sophie <info@soophie.de>
Date: Mon, 12 May 2025 21:07:27 +0000
feat: Updated README
Diffstat:
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
@@ -14,16 +14,16 @@ sudo make install
#define LIB_HTTP_IMPL
#include <libhttp.h>
-http_response_t do_handle(http_request_t *request) {
- http_response_t response = http_response_create(HTTP_STATUS_OK);
- http_header_set(&response, "Content-Type", "text/html");
- http_response_body(&response, "<h1>Hello, World!</h1>", 22);
- return response;
+HTTP_GET("/", index_page) {
+ (void) req;
+ http_resp_t resp = http_resp_create(HTTP_STATUS_OK);
+ http_resp_header(&resp, "Content-Type", "text/html");
+ http_resp_body(&resp, "<h1>Hello, World!</h1>", 22);
+ return resp;
}
int main(void) {
http_t *http = http_init();
- http_on_request(http, do_handle);
if (http_bind(http, "0.0.0.0", 80, NULL, 0) != HTTP_ERR_OK) {
printf("failed to bind port :80\n");
http_cleanup(http);