aboutsummaryrefslogtreecommitdiff
path: root/src/routes/api/image/load.zig
blob: 3ef25d618218e71864b7893443318539a853c34d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const std = @import("std");

const memora = @import("memora");
const Context = memora.Context;
const Storage = memora.Storage;
const mime = @import("../../../mime.zig");

pub const access = .users;

pub fn get(ctx: *Context) !memora.Stream {
    const id = ctx.request.head.target["/api/image/load/".len..];
    var image = Storage.Image { .id = id, .timestamp = null };
    ctx.response.headers.content_type = comptime mime.content_types.get(".jpeg") orelse unreachable;
    return .from_file(try image.file(ctx.storage));
}