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

40 lines
1.1 KiB
Zig

const std = @import("std");
const api = @import("api");
const controller_utils = @import("../../controllers.zig").helpers;
pub const global = struct {
pub const method = .GET;
pub const path = "/timelines/global";
pub const Query = api.TimelineArgs;
pub fn handler(req: anytype, res: anytype, srv: anytype) !void {
const results = try srv.globalTimeline(req.query);
try controller_utils.paginate(results, res, req.allocator);
}
};
pub const local = struct {
pub const method = .GET;
pub const path = "/timelines/local";
pub const Query = api.TimelineArgs;
pub fn handler(req: anytype, res: anytype, srv: anytype) !void {
const results = try srv.localTimeline(req.query);
try controller_utils.paginate(results, res, req.allocator);
}
};
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(results, res, req.allocator);
}
};