commit 7fe5e29fb96a3db6b9d8da1459b7139238fc1c07
parent 3a1e3719af911ad6724e616075570254c314f8f6
Author: Sophie <info@soophie.de>
Date: Tue, 11 Mar 2025 15:44:06 +0000
feat: Updated libhttp types
Diffstat:
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/libctl.h b/src/libctl.h
@@ -8,15 +8,15 @@ typedef struct ctl_ctx ctl_ctx_t;
typedef void (*ctl_fn_t)(char **ctl_out, ctl_ctx_t ctx);
struct ctl_ctx {
- http_request_t *request;
+ http_req_t *request;
char *title;
ctl_fn_t fn;
void *data;
};
void ctl_init(ctl_fn_t fn);
-http_response_t ctl_serve_page(http_request_t *request, const char *title, ctl_fn_t fn, void *data);
-http_response_t ctl_serve_component(http_request_t *request, ctl_fn_t fn, void *data);
+http_resp_t ctl_serve_page(http_req_t *request, const char *title, ctl_fn_t fn, void *data);
+http_resp_t ctl_serve_component(http_req_t *request, ctl_fn_t fn, void *data);
#ifdef LIB_CTL_IMPL
@@ -26,7 +26,7 @@ void ctl_init(ctl_fn_t fn) {
ctl_fn = fn;
}
-http_response_t ctl_serve_page(http_request_t *request, const char *title, ctl_fn_t fn, void *data) {
+http_resp_t ctl_serve_page(http_req_t *request, const char *title, ctl_fn_t fn, void *data) {
char *html = NULL;
ctl_ctx_t ctx = {
.request = request,
@@ -35,23 +35,23 @@ http_response_t ctl_serve_page(http_request_t *request, const char *title, ctl_f
.data = data,
};
ctl_fn(&html, ctx);
- http_response_t response = http_response_create(HTTP_STATUS_OK);
+ http_resp_t response = http_resp_create(HTTP_STATUS_OK);
http_header_set(&response, "Content-Type", "text/html");
- http_response_body(&response, html, strlen(html));
+ http_resp_body_set(&response, html, strlen(html));
free(html);
return response;
}
-http_response_t ctl_serve_component(http_request_t *request, ctl_fn_t fn, void *data) {
+http_resp_t ctl_serve_component(http_req_t *request, ctl_fn_t fn, void *data) {
char *html = NULL;
ctl_ctx_t ctx = {
.request = request,
.data = data,
};
fn(&html, ctx);
- http_response_t response = http_response_create(HTTP_STATUS_OK);
+ http_resp_t response = http_resp_create(HTTP_STATUS_OK);
http_header_set(&response, "Content-Type", "text/html");
- http_response_body(&response, html, strlen(html));
+ http_resp_body_set(&response, html, strlen(html));
free(html);
return response;
}