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

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

pub const access = .users;

pub fn get(ctx: *Context) !memora.Stream {
    const name = ctx.request.head.target["/api/profile/image/load/".len..];
    if (Storage.User.image(ctx.storage, name)) |file| {
        ctx.response.headers.content_type = "image/jpeg";
        return .from_file(file);
    }

    return error.NotFound;
}