1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
const httpz = @import("httpz");
const markers_repo = @import("../repos/markers_repo.zig");
const common = @import("common.zig");
pub fn list_by_map(env: *common.Env, req: *httpz.Request, res: *httpz.Response) !void {
const query = try req.query();
const map_id = query.get("map").?;
const maps = try markers_repo.get_markers(res.arena, env.conn, map_id);
try res.json(maps.items, .{});
}
pub fn create(env: *common.Env, req: *httpz.Request, res: *httpz.Response) !void {
const query = try req.query();
const map_id = query.get("map").?;
const payload = try common.with_body(markers_repo.Payload, req);
const marker = try markers_repo.create(res.arena, env.conn, map_id, payload);
try res.json(marker, .{});
}
pub fn update(env: *common.Env, req: *httpz.Request, res: *httpz.Response) !void {
const id = req.param("id").?;
const payload = try common.with_body(markers_repo.Payload, req);
const map = try markers_repo.update(env.conn, id, payload);
try res.json(map, .{});
}
pub fn delete(env: *common.Env, req: *httpz.Request, _: *httpz.Response) !void {
const id = req.param("id").?;
try markers_repo.delete(env.conn, id);
}
|