aboutsummaryrefslogtreecommitdiff
path: root/src/http/handler/static.zig
blob: df307b74006c809e7c63ecf702f555891a5dd3e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const Interface = @import("Interface.zig");
const Context = @import("context.zig").Context;
const Response = @import("../Response.zig");

pub fn Static(route: anytype, content: []const u8, mime: []const u8) Context(route) {
    const get = struct {
        fn get(_: Context(route).Request) Response {
            return .withHeaders(.ok, .string(content), &.{
                .{ .name = "Content-Type", .value = mime },
            });
        }
    }.get;

    return .{ .get = get };
}