aboutsummaryrefslogtreecommitdiff
path: root/src/http/RouteSet.zig
blob: 3b6bfa7211e3fcb0cca23e971a45b97986dc9eec (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const std = @import("std");

const Route = @import("Route.zig");
const handler = @import("handler.zig");
const Interface = handler.Interface;
const Context = handler.Context;

literals: []struct {
    value: []const u8,
    node: *@This(),
},
identifiers: []@This(),
interface: ?Interface,

pub fn init(comptime interfaces: []const Interface) @This() {
    _ = interfaces;
    return undefined;
}

pub fn getInterface(self: *const @This(), url: []const u8) ?Interface {
    _ = self;
    _ = url;
    return null;
}

test "init" {
    const M = struct {
        const Response = @import("Response.zig");

        const C = Context(.{ "api", "images", .id, "metadata" });
        const context: C = .{};

        const Query = struct {
            condition: []const u8,
            start: usize,
            length: usize,
        };

        pub fn get(request: C.Request) Response {
            _ = request;
            return .ok(.static("hello"));
        }
    };

    const routes = init(&.{M.context.interface()});

    const interface = routes.getInterface("/api/images/123456/metadata");
    _ = interface;
}