From f44dddb3be440af05abbe5d683c797f21d95eb00 Mon Sep 17 00:00:00 2001 From: Michael McVady Date: Thu, 19 Aug 2021 21:14:12 -0500 Subject: Working with assets --- assets/index_begin.html | 9 +++++++++ assets/index_end.html | 2 ++ conf/clog.conf | 14 +++++++++----- src/clog.c | 20 +++++++++++++++----- 4 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 assets/index_begin.html create mode 100644 assets/index_end.html diff --git a/assets/index_begin.html b/assets/index_begin.html new file mode 100644 index 0000000..6c14258 --- /dev/null +++ b/assets/index_begin.html @@ -0,0 +1,9 @@ + + + + +clog + + + +

clog posts

diff --git a/assets/index_end.html b/assets/index_end.html new file mode 100644 index 0000000..308b1d0 --- /dev/null +++ b/assets/index_end.html @@ -0,0 +1,2 @@ + + diff --git a/conf/clog.conf b/conf/clog.conf index 4264beb..08bd30d 100644 --- a/conf/clog.conf +++ b/conf/clog.conf @@ -4,13 +4,17 @@ server tls { bind 127.0.0.1 8888 } -load ./clog.so +load ./clog.so + +tls_dhparam dh2048.pem domain * { - attach tls + # attach notls + attach tls - certfile cert/server.pem - certkey cert/key.pem + certfile cert/server.pem + certkey cert/key.pem - route / page + route / page + route /posts page } diff --git a/src/clog.c b/src/clog.c index 31efef8..74564f0 100644 --- a/src/clog.c +++ b/src/clog.c @@ -1,12 +1,22 @@ #include #include -int page(struct http_request *); +#include "assets.h" -int -page(struct http_request *req) +int page(struct http_request *); + +int page(struct http_request *req) { - char *resp_body = "clog lives!\r\n"; - http_response(req, 200, resp_body, strlen(resp_body)); + struct kore_buf *buf; + buf = kore_buf_alloc(); + + kore_buf_append(buf, asset_index_begin_html, asset_len_index_begin_html); + kore_buf_append(buf, asset_index_end_html, asset_len_index_end_html); + + http_response_header(req, "content-type", "text/html; charset=utf-8"); + http_response(req, 200, buf->data, buf->offset); + // http_response_stream ??? + kore_buf_free(buf); + return (KORE_RESULT_OK); } -- cgit v1.2.3