fediglam/src/main/controllers/api/timelines.zig

42 lines
1.2 KiB
Zig
Raw Normal View History

2022-11-14 07:00:20 +00:00
const std = @import("std");
const api = @import("api");
2022-11-15 05:38:08 +00:00
const controller_utils = @import("../../controllers.zig").helpers;
2022-11-14 07:00:20 +00:00
2023-01-04 19:03:23 +00:00
const TimelineArgs = api.timelines.TimelineArgs;
2022-11-12 12:39:49 +00:00
pub const global = struct {
pub const method = .GET;
2022-11-27 01:52:30 +00:00
pub const path = "/timelines/global";
2022-11-12 12:39:49 +00:00
2023-01-04 19:03:23 +00:00
pub const Query = TimelineArgs;
2022-11-14 07:00:20 +00:00
pub fn handler(req: anytype, res: anytype, srv: anytype) !void {
const results = try srv.globalTimeline(req.query);
2022-11-27 09:59:37 +00:00
try controller_utils.paginate(results, res, req.allocator);
2022-11-12 12:39:49 +00:00
}
};
2022-11-12 13:23:55 +00:00
pub const local = struct {
pub const method = .GET;
2022-11-27 01:52:30 +00:00
pub const path = "/timelines/local";
2022-11-12 13:23:55 +00:00
2023-01-04 19:03:23 +00:00
pub const Query = TimelineArgs;
2022-11-14 07:00:20 +00:00
pub fn handler(req: anytype, res: anytype, srv: anytype) !void {
const results = try srv.localTimeline(req.query);
2022-11-27 09:59:37 +00:00
try controller_utils.paginate(results, res, req.allocator);
2022-11-12 13:23:55 +00:00
}
};
2022-11-14 23:00:01 +00:00
pub const home = struct {
pub const method = .GET;
2022-11-27 01:52:30 +00:00
pub const path = "/timelines/home";
2022-11-14 23:00:01 +00:00
2023-01-04 19:03:23 +00:00
pub const Query = TimelineArgs;
2022-11-14 23:00:01 +00:00
pub fn handler(req: anytype, res: anytype, srv: anytype) !void {
const results = try srv.homeTimeline(req.query);
2022-11-27 09:59:37 +00:00
try controller_utils.paginate(results, res, req.allocator);
2022-11-14 23:00:01 +00:00
}
};