aboutsummaryrefslogtreecommitdiff
path: root/src/http/Response.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/http/Response.zig')
-rw-r--r--src/http/Response.zig28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/http/Response.zig b/src/http/Response.zig
new file mode 100644
index 0000000..a5f7727
--- /dev/null
+++ b/src/http/Response.zig
@@ -0,0 +1,28 @@
+const std = @import("std");
+
+pub const Message = union(enum) {
+ void: void,
+ static: []const u8,
+ file_content: std.Io.File,
+
+ pub fn string(content: []const u8) Message {
+ return .{ .static = content };
+ }
+
+ pub fn file(io: std.Io, path: []const u8) !Message {
+ return .{ .file_content = try std.Io.Dir.cwd().openFile(io, path, .{
+ .allow_directory = false,
+ }) };
+ }
+};
+
+status: std.http.Status,
+message: Message,
+
+pub fn with(status: std.http.Status, message: Message) @This() {
+ return .{ .status = status, .message = message };
+}
+
+pub fn ok(message: Message) @This() {
+ return with(.ok, message);
+}