aboutsummaryrefslogtreecommitdiff
path: root/comments
diff options
context:
space:
mode:
authorMartin Ashby <martin@ashbysoft.com>2024-02-01 14:39:26 +0000
committerMartin Ashby <martin@ashbysoft.com>2024-02-01 14:39:26 +0000
commit8b47802e383dde95650f9d24e88c2f67f6596a98 (patch)
tree079ed8f37b793036812b8732b8625bc423e03572 /comments
parenta3ed80acdbd1b92e61fbe50b0e38e05e82583503 (diff)
downloadmfashby.net-8b47802e383dde95650f9d24e88c2f67f6596a98.tar.gz
mfashby.net-8b47802e383dde95650f9d24e88c2f67f6596a98.tar.bz2
mfashby.net-8b47802e383dde95650f9d24e88c2f67f6596a98.tar.xz
mfashby.net-8b47802e383dde95650f9d24e88c2f67f6596a98.zip
Update for zig master
Diffstat (limited to 'comments')
-rw-r--r--comments/build.zig18
-rw-r--r--comments/build.zig.zon34
-rw-r--r--comments/src/main.zig41
3 files changed, 45 insertions, 48 deletions
diff --git a/comments/build.zig b/comments/build.zig
index eb8f8fb..3293e4c 100644
--- a/comments/build.zig
+++ b/comments/build.zig
@@ -27,20 +27,20 @@ pub fn build(b: *std.Build) void {
});
const zws = b.dependency("zigwebserver", opts);
- exe.addModule("zws", zws.module("zigwebserver"));
- exe.linkLibrary(zws.artifact("zigwebserver"));
+ exe.root_module.addImport("zws", zws.module("zigwebserver"));
const pq = b.dependency("pq", opts);
- exe.addModule("pq", pq.module("pq"));
- exe.linkLibrary(pq.artifact("pq"));
+ exe.root_module.addImport("pq", pq.module("pq"));
+ exe.linkLibC();
+ exe.linkSystemLibrary("pq");
const mustache = b.dependency("mustache", opts);
- exe.addModule("mustache", mustache.module("mustache"));
- exe.linkLibrary(mustache.artifact("mustache-static"));
+ exe.root_module.addImport("mustache", mustache.module("mustache"));
const smtp = b.dependency("smtp", opts);
- exe.addModule("smtp", smtp.module("smtp"));
- exe.linkLibrary(smtp.artifact("smtp"));
+ exe.root_module.addImport("smtp", smtp.module("smtp"));
+
+
// This declares intent for the executable to be installed into the
// standard location when the user invokes the "install" step (the default
@@ -77,7 +77,7 @@ pub fn build(b: *std.Build) void {
.target = target,
.optimize = optimize,
});
- unit_tests.addModule("mustache", mustache.module("mustache"));
+ unit_tests.root_module.addImport("mustache", mustache.module("mustache"));
const run_unit_tests = b.addRunArtifact(unit_tests);
diff --git a/comments/build.zig.zon b/comments/build.zig.zon
index 5efceff..ebb6cf2 100644
--- a/comments/build.zig.zon
+++ b/comments/build.zig.zon
@@ -1,22 +1,18 @@
.{
.name = "comments",
.version = "0.0.1",
- .dependencies = .{
- .pq = .{
- .url = "https://code.mfashby.net/pq-zig/snapshot/pq-zig-main.tar.xz",
- .hash = "1220002a8cba96583acc07775b060911c9bd74271fb127992ac21854a12274c4ab48",
- },
- .smtp = .{
- .url = "https://code.mfashby.net/smtp-zig/snapshot/smtp-zig-main.tar.xz",
- .hash = "1220d9279300c447871a56b8eec1a7f179b99a971b37923cb42ccf6afd3b24b9eaa0",
- },
- .mustache = .{
- .url = "https://github.com/MFAshby/mustache-zig/archive/refs/heads/stage3.tar.gz",
- .hash = "1220fdf239b6ece687324bb600c72d5ad7a278df2ece86599aee6adf932064686cef",
- },
- .zigwebserver = .{
- .url = "https://code.mfashby.net/zigwebserver/snapshot/zigwebserver-main.tar.xz",
- .hash = "122066ea438ccbe3e006e84563746705cd46f3c7d1389c8fa8cccf2cdf681959495e",
- }
- }
-} \ No newline at end of file
+ .dependencies = .{ .pq = .{
+ .url = "https://code.mfashby.net/pq-zig/snapshot/pq-zig-main.tar.xz",
+ .hash = "12201517d080461a76f4b26ff78a810d80b1d58e2d3f382da30de1055ebdcea3feaf",
+ }, .smtp = .{
+ .url = "https://code.mfashby.net/smtp-zig/snapshot/smtp-zig-main.tar.xz",
+ .hash = "1220b85b46b525e725f8fdb6e23189aa365976acf388e3b2a5a4da364851c3ec4252",
+ }, .mustache = .{
+ .url = "https://github.com/batiati/mustache-zig/archive/refs/heads/master.tar.gz",
+ .hash = "122099facef1728bd1118fac3a9444f5daca7278046e734a25f03f7e20bad2b5cb28",
+ }, .zigwebserver = .{
+ .url = "https://code.mfashby.net/zigwebserver/snapshot/zigwebserver-main.tar.xz",
+ .hash = "122084fc67129e92544a86f10ca9a64f2667682aa7dfd6a12a80c374015a33555df6",
+ } },
+ .paths = .{""},
+}
diff --git a/comments/src/main.zig b/comments/src/main.zig
index 8710d95..ac8193e 100644
--- a/comments/src/main.zig
+++ b/comments/src/main.zig
@@ -7,33 +7,34 @@ const smtp = @import("smtp");
const Params = zws.Params;
const Err = error{
- Unexpected,
AccessDenied,
- OutOfMemory,
- InputOutput,
- SystemResources,
- IsDir,
- OperationAborted,
BrokenPipe,
+ ColumnNotFound,
ConnectionResetByPeer,
ConnectionTimedOut,
- NotOpenForReading,
- NetNameDeleted,
- WouldBlock,
- StreamTooLong,
- Malformatted,
- InvalidLength,
- InvalidCharacter,
- NoSpaceLeft,
- PqError,
- ColumnNotFound,
+ DeviceBusy,
DiskQuota,
FileTooBig,
- DeviceBusy,
+ InputOutput,
InvalidArgument,
- NotOpenForWriting,
- LockViolation,
+ InvalidCharacter,
+ InvalidLength,
InvalidRequestMethod,
+ IsDir,
+ LockViolation,
+ Malformatted,
+ NetNameDeleted,
+ NoSpaceLeft,
+ NotOpenForReading,
+ NotOpenForWriting,
+ OperationAborted,
+ OutOfMemory,
+ PqError,
+ SocketNotConnected,
+ StreamTooLong,
+ SystemResources,
+ Unexpected,
+ WouldBlock,
};
const Ctx = struct {
db: pq.Db,
@@ -204,7 +205,7 @@ fn get_comment(res: *Response, ctx: Ctx, _: Params) Err!void {
fn post_comment(res: *Response, ctx: Ctx, _: Params) Err!void {
var body_aa = std.ArrayList(u8).init(res.allocator);
try res.reader().readAllArrayList(&body_aa, 1_000_000);
- var body = try body_aa.toOwnedSlice();
+ const body = try body_aa.toOwnedSlice();
var form = try zws.Form.parse(res.allocator, body);
const Form = struct {
url: []const u8,