aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.zig10
-rw-r--r--build.zig.zon2
-rw-r--r--flake.nix4
-rw-r--r--src/http.zig1
-rw-r--r--src/main.zig18
5 files changed, 16 insertions, 19 deletions
diff --git a/build.zig b/build.zig
index 05f6350..53ede62 100644
--- a/build.zig
+++ b/build.zig
@@ -28,7 +28,7 @@ pub fn build(b: *std.Build) void {
// to our consumers. We must give it a name because a Zig package can expose
// multiple modules and consumers will need to be able to specify which
// module they want to access.
- const mod = b.addModule("storyboard", .{
+ const mod = b.addModule("memora", .{
// The root source file is the "entry point" of this module. Users of
// this module will only be able to access public declarations contained
// in this file, which means that if you have declarations that you
@@ -58,7 +58,7 @@ pub fn build(b: *std.Build) void {
// If neither case applies to you, feel free to delete the declaration you
// don't need and to put everything under a single module.
const exe = b.addExecutable(.{
- .name = "storyboard",
+ .name = "memora",
.root_module = b.createModule(.{
// b.createModule defines a new module just like b.addModule but,
// unlike b.addModule, it does not expose the module to consumers of
@@ -73,12 +73,12 @@ pub fn build(b: *std.Build) void {
// List of modules available for import in source files part of the
// root module.
.imports = &.{
- // Here "storyboard" is the name you will use in your source code to
- // import this module (e.g. `@import("storyboard")`). The name is
+ // Here "memora" is the name you will use in your source code to
+ // import this module (e.g. `@import("memora")`). The name is
// repeated because you are allowed to rename your imports, which
// can be extremely useful in case of collisions (which can happen
// importing modules from different packages).
- .{ .name = "storyboard", .module = mod },
+ .{ .name = "memora", .module = mod },
},
}),
});
diff --git a/build.zig.zon b/build.zig.zon
index 67eca1f..352c4f1 100644
--- a/build.zig.zon
+++ b/build.zig.zon
@@ -6,7 +6,7 @@
//
// It is redundant to include "zig" in this name because it is already
// within the Zig package namespace.
- .name = .storyboard,
+ .name = .memora,
// This is a [Semantic Version](https://semver.org/).
// In a future version of Zig it will be used for package deduplication.
.version = "0.0.0",
diff --git a/flake.nix b/flake.nix
index bcf3861..ce7acb6 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,5 +1,5 @@
{
- description = "Storyboard";
+ description = "Memora";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
@@ -13,7 +13,7 @@
devShells.x86_64-linux.default = pkgs.mkShell {
packages = [
pkgs.zig
- pkgs.psmisc
+ pkgs.http-server
];
};
};
diff --git a/src/http.zig b/src/http.zig
index e8ecfcf..ad4ecb6 100644
--- a/src/http.zig
+++ b/src/http.zig
@@ -11,7 +11,6 @@ pub fn respond_file(
const suffix_pos = std.mem.lastIndexOfScalar(u8, file_name, '.') orelse file_name.len;
const suffix = file_name[suffix_pos..];
- std.debug.print("{s}, {}, suffix: {s}\n", .{file_name, suffix_pos, suffix});
try request.respond(buffer, .{
.extra_headers = &.{
diff --git a/src/main.zig b/src/main.zig
index b98b112..2566120 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -1,8 +1,8 @@
const std = @import("std");
-const storyboard = @import("storyboard");
+const memora = @import("memora");
pub const std_options = std.Options {
- .logFn = storyboard.log.handler,
+ .logFn = memora.log.handler,
};
const log = std.log.scoped(.main);
@@ -32,15 +32,13 @@ pub fn main() !void {
var writer = connection.stream.writer(&write_buf);
var http_server = std.http.Server.init(reader.interface(), &writer.interface);
- while (true) {
- var request = http_server.receiveHead() catch break;
- log.info("{} {s}", .{request.head.method, request.head.target});
+ var request = http_server.receiveHead() catch continue;
+ log.info("{} {s}", .{request.head.method, request.head.target});
- const handler = storyboard.routes.get(request.head.target);
+ const handler = memora.routes.get(request.head.target);
- handler(&request, allocator) catch |err| {
- log.err("handler({s}): {}", .{request.head.target, err});
- };
- }
+ handler(&request, allocator) catch |err| {
+ log.err("handler({s}): {}", .{request.head.target, err});
+ };
}
}