@@ -4,7 +4,6 @@ const Allocator = std.mem.Allocator;
const Verse = @import("verse.zig");
const Router = @import("router.zig");
/// Thin wrapper for zWSGI
pub const Server = @This();
pub const zWSGI = @import("zwsgi.zig");
@@ -12,7 +11,6 @@ pub const Http = @import("http.zig");
alloc: Allocator,
router: Router,
//runmode: RunMode,
interface: union(RunMode) {
unix: zWSGI,
http: Http,
@@ -26,19 +24,17 @@ pub const RunMode = enum {
};
pub const Options = struct {
file: []const u8 = "./zwsgi_file.sock",
host: []const u8 = "127.0.0.1",
port: u16 = 80,
zwsgi: zWSGI.Options = .{},
http: Http.Options = .{},
};
pub fn init(a: Allocator, runmode: RunMode, router: Router, opts: Options) !Server {
return .{
.alloc = a,
//.config = config,
.router = router,
.interface = switch (runmode) {
.unix => .{ .unix = zWSGI.init(a, opts.file, router) },
.http => .{ .http = try Http.init(a, opts.host, opts.port, router) },
.unix => .{ .unix = zWSGI.init(a, opts.zwsgi, router) },
.http => .{ .http = try Http.init(a, opts.http, router) },
.other => unreachable,
},
};