rename web/ to admin/, along with the web-named build and cli identifiers
This commit is contained in:
+10
-10
@@ -1,7 +1,7 @@
|
||||
//! Static asset serving (milestone-8 ruling 24).
|
||||
//!
|
||||
//! Production serves from `web_assets`, the module the build generates from
|
||||
//! `-Dweb-dist`: bytes, content type and a strong ETag per file, plus a
|
||||
//! Production serves from `admin_assets`, the module the build generates from
|
||||
//! `-Dadmin-dist`: bytes, content type and a strong ETag per file, plus a
|
||||
//! `<name>.gz` sibling entry where compressing at build time paid off. Serving
|
||||
//! is a linear scan over a handful of immutable entries — no allocation, no
|
||||
//! clock, no disk.
|
||||
@@ -18,12 +18,12 @@
|
||||
//! ETag so a `304` is always judged against the representation that would be
|
||||
//! served.
|
||||
//!
|
||||
//! Dev mode (`nxdns run --web-dev <dir>`, wired by the CLI) serves from disk
|
||||
//! Dev mode (`nxdns run --admin-dev <dir>`, wired by the CLI) serves from disk
|
||||
//! with no cache headers, so a UI developer sees an edit on reload.
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
const assets = @import("web_assets");
|
||||
const assets = @import("admin_assets");
|
||||
const http_util = @import("http_util.zig");
|
||||
const server = @import("server.zig");
|
||||
|
||||
@@ -37,7 +37,7 @@ pub const embedded: []const File = assets.files;
|
||||
pub const index_path = "/index.html";
|
||||
|
||||
/// A disk asset a dev-mode request may read. Matches the embed limit in
|
||||
/// tools/gen_web_assets.zig.
|
||||
/// tools/gen_admin_assets.zig.
|
||||
pub const max_disk_asset_bytes = 64 * 1024 * 1024;
|
||||
|
||||
pub const Selection = struct {
|
||||
@@ -193,7 +193,7 @@ pub fn diskRelativePath(buf: []u8, segments: []const []const u8) ?[]const u8 {
|
||||
return writer.buffered();
|
||||
}
|
||||
|
||||
/// Dev-mode disk serving for `--web-dev` (ruling 24). No cache headers: the
|
||||
/// Dev-mode disk serving for `--admin-dev` (ruling 24). No cache headers: the
|
||||
/// point of the flag is that an edit shows up on the next reload. The CLI
|
||||
/// wiring (W9) closes over the directory and passes it here.
|
||||
pub fn serveFromDisk(
|
||||
@@ -209,8 +209,8 @@ pub fn serveFromDisk(
|
||||
return http_util.respondError(request, .not_found, "not found");
|
||||
|
||||
var dir = std.Io.Dir.cwd().openDir(io, root, .{}) catch |err| {
|
||||
log.warn("web-dev directory '{s}' is unreadable: {t}", .{ root, err });
|
||||
return http_util.respondError(request, .internal_server_error, "web-dev directory unavailable");
|
||||
log.warn("admin-dev directory '{s}' is unreadable: {t}", .{ root, err });
|
||||
return http_util.respondError(request, .internal_server_error, "admin-dev directory unavailable");
|
||||
};
|
||||
defer dir.close(io);
|
||||
|
||||
@@ -233,7 +233,7 @@ fn readDiskFile(
|
||||
return dir.readFileAlloc(io, sub_path, request.arena, .limited(max_disk_asset_bytes)) catch |err| {
|
||||
switch (err) {
|
||||
error.FileNotFound, error.IsDir => {},
|
||||
else => log.warn("web-dev read of '{s}' failed: {t}", .{ sub_path, err }),
|
||||
else => log.warn("admin-dev read of '{s}' failed: {t}", .{ sub_path, err }),
|
||||
}
|
||||
return null;
|
||||
};
|
||||
@@ -255,7 +255,7 @@ fn resolvesUnderRoot(dir: std.Io.Dir, io: std.Io, sub_path: []const u8) bool {
|
||||
}
|
||||
|
||||
/// Extension → MIME type for dev-mode disk serving. The embedded entries carry
|
||||
/// the same mapping, stamped by tools/gen_web_assets.zig; a test below keeps
|
||||
/// the same mapping, stamped by tools/gen_admin_assets.zig; a test below keeps
|
||||
/// the two from drifting.
|
||||
pub fn contentType(path: []const u8) []const u8 {
|
||||
const map = [_]struct { ext: []const u8, mime: []const u8 }{
|
||||
|
||||
Reference in New Issue
Block a user