diff options
author | Martin Ashby <martin@ashbysoft.com> | 2024-03-25 21:36:21 +0000 |
---|---|---|
committer | Martin Ashby <martin@ashbysoft.com> | 2024-03-25 21:36:21 +0000 |
commit | 92787c159262a57fa20b2eb05ed710e1e6cfca96 (patch) | |
tree | 508cab2af110a063767564571a98d157926bfb05 /comments/src/main.zig | |
parent | e12c0d23ad72ffa9389d90311453db535f57e450 (diff) | |
download | mfashby.net-92787c159262a57fa20b2eb05ed710e1e6cfca96.tar.gz mfashby.net-92787c159262a57fa20b2eb05ed710e1e6cfca96.tar.bz2 mfashby.net-92787c159262a57fa20b2eb05ed710e1e6cfca96.tar.xz mfashby.net-92787c159262a57fa20b2eb05ed710e1e6cfca96.zip |
Final conversion to Zine
Diffstat (limited to 'comments/src/main.zig')
-rw-r--r-- | comments/src/main.zig | 16 |
1 files changed, 8 insertions, 8 deletions
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}); }; |