summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--http.zig42
1 files changed, 42 insertions, 0 deletions
diff --git a/http.zig b/http.zig
index 6b86d14..eb10a88 100644
--- a/http.zig
+++ b/http.zig
@@ -9,6 +9,7 @@ const MAX_BUF = 1024;
const Endpoint = enum {
root_get,
login_get,
+ create_account_get,
};
pub fn serve(io: std.Io, address: []const u8, port: u16) !void {
@@ -57,6 +58,8 @@ fn endpointFromRequest(request: *Request) !Endpoint {
return .root_get;
} else if (head.method == .GET and std.mem.eql(u8, head.target, "/login")) {
return .login_get;
+ } else if (head.method == .GET and std.mem.eql(u8, head.target, "/create-account")) {
+ return .create_account_get;
}
return error.InvalidEndpoint;
}
@@ -71,6 +74,7 @@ fn serveHTTP(request: *Request) !void {
switch (endpoint) {
.root_get => try handleRoot(request),
.login_get => try handleLogin(request),
+ .create_account_get => try handleCreateAccountGet(request),
}
}
@@ -85,3 +89,41 @@ fn handleRoot(request: *Request) !void {
fn handleLogin(request: *Request) !void {
try request.respond("Login page\n", .{});
}
+
+fn handleCreateAccountGet(request: *Request) !void {
+ try request.respond(
+ \\<!DOCTYPE html>
+ \\<html>
+ \\ <head>
+ \\ <meta charset="utf-8">
+ \\ <meta name="viewport" content="width=device-width, inital-scale=1">
+ \\ <title>Coinvane</title>
+ \\ <style type="text/css">
+ \\ body{
+ \\ margin: 40px auto;
+ \\ max-width: 650px;
+ \\ line-height: 1.6;
+ \\ font-size: 18px;
+ \\ color: #444;
+ \\ padding: 0 10px
+ \\ }
+ \\ h1,h2,h3{
+ \\ line-height: 1.2
+ \\ }
+ \\ </style>
+ \\ </head>
+ \\ <body>
+ \\ <header>
+ \\ <h1>Create Account</h1>
+ \\ </header>
+ \\ <form action="/create-account" method="POST">
+ \\ <label for="email">Email:</label>
+ \\ <input type="email" id="email" name="email" required>
+ \\ <label for="password">Password:</label>
+ \\ <input type="password" id="password" name="password required>
+ \\ <input type="submit" value="Submit">
+ \\ </form>
+ \\ </body>
+ \\</html>
+ , .{});
+}