diff options
Diffstat (limited to 'comments')
-rw-r--r-- | comments/build.zig.zon | 2 | ||||
-rw-r--r-- | comments/src/main.zig | 16 |
2 files changed, 9 insertions, 9 deletions
diff --git a/comments/build.zig.zon b/comments/build.zig.zon index ebb6cf2..edc18d7 100644 --- a/comments/build.zig.zon +++ b/comments/build.zig.zon @@ -9,7 +9,7 @@ .hash = "1220b85b46b525e725f8fdb6e23189aa365976acf388e3b2a5a4da364851c3ec4252", }, .mustache = .{ .url = "https://github.com/batiati/mustache-zig/archive/refs/heads/master.tar.gz", - .hash = "122099facef1728bd1118fac3a9444f5daca7278046e734a25f03f7e20bad2b5cb28", + .hash = "12205538be57d7c0b92806e87c500c50bfcecb9b083adea8b2fdbec99f46598c922d", }, .zigwebserver = .{ .url = "https://code.mfashby.net/zigwebserver/snapshot/zigwebserver-main.tar.xz", .hash = "122084fc67129e92544a86f10ca9a64f2667682aa7dfd6a12a80c374015a33555df6", diff --git a/comments/src/main.zig b/comments/src/main.zig index 4044ae7..a5008b8 100644 --- a/comments/src/main.zig +++ b/comments/src/main.zig @@ -130,16 +130,16 @@ const router = Rtr{ /// Run as a CGI program! pub fn main() !void { const allocator = gpa.allocator(); - const db_url = std.os.getenv("DATABASE_URL") orelse "postgresql://comments@localhost/comments"; + const db_url = std.posix.getenv("DATABASE_URL") orelse "postgresql://comments@localhost/comments"; var db = try pq.Db.init(db_url); // try db.exec(@embedFile("migrations/0_init.sql")); // try db.exec(@embedFile("migrations/1_capcha.sql")); defer db.deinit(); const req = Request{ - .method = std.meta.stringToEnum(std.http.Method, std.os.getenv("REQUEST_METHOD") orelse "GET") orelse { + .method = std.meta.stringToEnum(std.http.Method, std.posix.getenv("REQUEST_METHOD") orelse "GET") orelse { return error.InvalidRequestMethod; }, - .target = std.os.getenv("REQUEST_URI") orelse "/", + .target = std.posix.getenv("REQUEST_URI") orelse "/", }; var res = Response{ .allocator = allocator, @@ -211,7 +211,7 @@ fn get_comment(res: *Response, ctx: Ctx, _: Params) Err!void { } fn post_comment(res: *Response, ctx: Ctx, _: Params) Err!void { - const cl = if (std.os.getenv("CONTENT_LENGTH")) |clh| try std.fmt.parseInt(usize, clh, 10) else { + const cl = if (std.posix.getenv("CONTENT_LENGTH")) |clh| try std.fmt.parseInt(usize, clh, 10) else { return error.InvalidLength; }; const body = try res.allocator.alloc(u8, cl); @@ -268,10 +268,10 @@ fn post_comment(res: *Response, ctx: Ctx, _: Params) Err!void { .author = form_val.author, .comment = form_val.comment, }); - const smtp_username = std.os.getenv("SMTP_USERNAME") orelse "comments@mfashby.net"; - const smtp_password = std.os.getenv("SMTP_PASSWORD") orelse "foobar"; - const notification_address = std.os.getenv("NOTIFICATION_ADDRESS") orelse "martin@mfashby.net"; - const smtp_server = std.os.getenv("SMTP_SERVER") orelse "mail.mfashby.net:587"; + const smtp_username = std.posix.getenv("SMTP_USERNAME") orelse "comments@mfashby.net"; + const smtp_password = std.posix.getenv("SMTP_PASSWORD") orelse "foobar"; + const notification_address = std.posix.getenv("NOTIFICATION_ADDRESS") orelse "martin@mfashby.net"; + const smtp_server = std.posix.getenv("SMTP_SERVER") orelse "mail.mfashby.net:587"; smtp.send_mail(res.allocator, smtp_server, .{ .user = smtp_username, .pass = smtp_password }, smtp_username, &[_][]const u8{notification_address}, notification) catch |err| { std.log.err("failed to send notification email {}", .{err}); }; |