diff --git a/src/http.zig b/src/http.zig index 8c25558..6c2ef45 100644 --- a/src/http.zig +++ b/src/http.zig @@ -1,5 +1,4 @@ const std = @import("std"); -const fio = @import("fio.zig"); /// HTTP Status codes according to `rfc9110` /// https://datatracker.ietf.org/doc/html/rfc9110#name-status-codes @@ -149,20 +148,3 @@ pub fn methodToEnum(method: ?[]const u8) Method { return Method.UNKNOWN; } } - -/// Registers a new mimetype to be used for files ending with the given extension. -pub fn mimetypeRegister(file_extension: []const u8, mime_type_str: []const u8) void { - // NOTE: facil.io is expecting a non-const pointer to u8 values, but it does not - // not appear to actually modify the value. Here we do a const cast so - // that it is easy to pass static strings to http_mimetype_register without - // needing to allocate a buffer on the heap. - const extension = @constCast(file_extension); - const mimetype = fio.fiobj_str_new(mime_type_str.ptr, mime_type_str.len); - - fio.http_mimetype_register(extension.ptr, extension.len, mimetype); -} - -/// Clears the Mime-Type registry (it will be empty after this call). -pub fn mimetypeClear() void { - fio.http_mimetype_clear(); -} diff --git a/src/zap.zig b/src/zap.zig index b8ab289..695c4b5 100644 --- a/src/zap.zig +++ b/src/zap.zig @@ -122,6 +122,23 @@ pub fn startWithLogging(args: fio.fio_start_args) void { fio.fio_start(args); } +/// Registers a new mimetype to be used for files ending with the given extension. +pub fn mimetypeRegister(file_extension: []const u8, mime_type_str: []const u8) void { + // NOTE: facil.io is expecting a non-const pointer to u8 values, but it does not + // not appear to actually modify the value. Here we do a const cast so + // that it is easy to pass static strings to http_mimetype_register without + // needing to allocate a buffer on the heap. + const extension = @constCast(file_extension); + const mimetype = fio.fiobj_str_new(mime_type_str.ptr, mime_type_str.len); + + fio.http_mimetype_register(extension.ptr, extension.len, mimetype); +} + +/// Clears the Mime-Type registry (it will be empty after this call). +pub fn mimetypeClear() void { + fio.http_mimetype_clear(); +} + pub const ListenError = error{ AlreadyListening, ListenError,