diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2025-11-17 09:57:09 +0100 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2025-11-17 09:57:09 +0100 |
| commit | e95cf5c7b6a08eb560763d5167fbddc1c2117bcc (patch) | |
| tree | 2f7815c9f39328fcaced2113de727f63e4837fa3 /src/routes/api/image/list.zig | |
| parent | 0016aaa197697ec5ff38dfb3f63ac8b6f74b48e0 (diff) | |
add file uploading and multi-threading
Diffstat (limited to 'src/routes/api/image/list.zig')
| -rw-r--r-- | src/routes/api/image/list.zig | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/routes/api/image/list.zig b/src/routes/api/image/list.zig new file mode 100644 index 0000000..ee7a648 --- /dev/null +++ b/src/routes/api/image/list.zig @@ -0,0 +1,30 @@ +const std = @import("std"); +const Context = @import("../../context.zig"); +const Storage = @import("../../../storage/root.zig"); + +pub const access = .users; + +const ImageInfo = struct { + id: []const u8, +}; + +const Result = struct { + images: []ImageInfo, +}; + +pub fn get(ctx: *Context) !Result { + var images: std.ArrayList(ImageInfo) = .empty; + + const images_list = ctx.storage.images.list(); + defer images_list.deinit(); + + for (images_list.images) |*image| { + try images.append(ctx.allocator, .{ + .id = image.id + }); + } + + return .{ + .images = try images.toOwnedSlice(ctx.allocator), + }; +} |