○
Planned This feature is planned but not yet implemented.
Requires a transform to handle pattern branches.
Error Details
output_emitted.zig:84:17: error: switch on type 'output_emitted.main_module.Request'
Failure Output
Showing last 10 of 13 lines
^~~~~~~~
output_emitted.zig:58:25: note: struct declared here
pub const Request = struct {
^~~~~~
referenced by:
main: output_emitted.zig:877:22
callMain [inlined]: /opt/homebrew/Cellar/zig/0.15.2_1/lib/zig/std/start.zig:618:22
callMainWithArgs [inlined]: /opt/homebrew/Cellar/zig/0.15.2_1/lib/zig/std/start.zig:587:20
main: /opt/homebrew/Cellar/zig/0.15.2_1/lib/zig/std/start.zig:602:28
1 reference(s) hidden; use '-freference-trace=5' to see all references Code
// Test: Pattern branch dispatch
//
// Pattern branches should dispatch based on matching the pattern against
// the event's return value. This test uses actual pattern branch syntax.
//
// The transform should:
// 1. Detect pattern branches (branch name starts with '[')
// 2. Parse the pattern to extract method + path template
// 3. Generate dispatch code that matches against the payload
// 4. Extract path params into the binding
~import std/io
const std = @import("std");
// Request type - the payload we're matching against
pub const Request = struct {
method: []const u8,
path: []const u8,
};
// Params extracted from path
pub const Params = struct {
id: ?[]const u8 = null,
};
// Event that returns a request
~pub tor incoming {} -> Request
~proc incoming|zig {
return .{ .method = "GET", .path = "/users/42" };
}
// This is what we WANT to work:
// Pattern branches dispatch based on matching method + path
~incoming()
| [GET /users/:id] p |> std/io:print.ln("user id: {{ p.id:s }}")
| [GET /health] _ |> std/io:print.ln("health check")
| [POST /users] _ |> std/io:print.ln("create user")
| [*] _ |> std/io:print.ln("not found")
Flows
flow ~incoming click a branch to expand · @labels scroll to their anchor
incoming