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

40 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
2022-11-12 12:39:49 +00:00
pub const global = struct {
pub const method = .GET;
pub const path = "/timelines/global";
2022-11-14 07:00:20 +00:00
pub const Query = api.TimelineArgs;
pub fn handler(req: anytype, res: anytype, srv: anytype) !void {
const results = try srv.globalTimeline(req.query);
2022-11-14 08:25:52 +00:00
try controller_utils.paginate(srv.community, path, 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;
pub const path = "/timelines/local";
2022-11-14 07:00:20 +00:00
pub const Query = api.TimelineArgs;
pub fn handler(req: anytype, res: anytype, srv: anytype) !void {
const results = try srv.localTimeline(req.query);
2022-11-14 08:25:52 +00:00
try controller_utils.paginate(srv.community, path, 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;
pub const path = "/timelines/home";
pub const Query = api.TimelineArgs;
pub fn handler(req: anytype, res: anytype, srv: anytype) !void {
const results = try srv.homeTimeline(req.query);
try controller_utils.paginate(srv.community, path, results, res, req.allocator);
}
};