aboutsummaryrefslogtreecommitdiff
path: root/login_get.c
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi92@disroot.org>2025-09-22 17:32:44 +0200
committerXavier Del Campo Romero <xavi92@disroot.org>2026-02-13 09:57:39 +0100
commit78bf2fe4a5bf37514f6dfd203ef969da0bf40c2e (patch)
tree33f9440b8ee0fa7a3b3ad033616d722d2101bb4d /login_get.c
parent107a2e43d54f9a42fb85b00b83cb0d9abb194680 (diff)
Setup project skeletonHEADmaster
Diffstat (limited to 'login_get.c')
-rw-r--r--login_get.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/login_get.c b/login_get.c
new file mode 100644
index 0000000..0699cbc
--- /dev/null
+++ b/login_get.c
@@ -0,0 +1,49 @@
+#define _POSIX_C_SOURCE 200809L
+
+#include "endpoints.h"
+#include "defs.h"
+#include <libweb/http.h>
+
+#define LOGIN_BODY \
+ "<header>\n" \
+ " <a href=\"" PROJECT_URL "\">" PROJECT_NAME "</a>, " \
+ PROJECT_DESC "\n" \
+ "</header>\n" \
+ " <form class=\"loginform\" action=\"/login\" method=\"post\">\n" \
+ " <label for=\"username\">Username:</label>\n" \
+ " <input type=\"text\" class=\"form-control\"\n" \
+ " id=\"username\" name=\"username\" autofocus><br>\n" \
+ " <label for=\"username\">Password:</label>\n" \
+ " <input type=\"password\" class=\"form-control\" \n" \
+ " id=\"password\" name=\"password\"><br>\n" \
+ " <input type=\"submit\" value=\"Submit\">\n" \
+ " </form>\n"
+
+int ep_login_get(const struct http_payload *const p,
+ struct http_response *const r, void *const user)
+{
+ static const char body[] =
+ DOCTYPE_TAG
+ "<html>\n"
+ " <head>\n"
+ " " STYLE_A "\n"
+ " " COMMON_HEAD "\n"
+ " </head>\n"
+ " " LOGIN_BODY "\n"
+ "</html>\n";
+
+ *r = (const struct http_response)
+ {
+ .status = HTTP_STATUS_OK,
+ .buf.ro = body,
+ .n = sizeof body - 1
+ };
+
+ if (http_response_add_header(r, "Content-Type", "text/html"))
+ {
+ fprintf(stderr, "%s: http_response_add_header failed\n", __func__);
+ return -1;
+ }
+
+ return 0;
+}