Browse Source

[Zig] Update ZZZ (#9745)

* chore(main): update date header

* chore(README.md): fix typo
Kayden 4 months ago
parent
commit
ab110c2c14
2 changed files with 7 additions and 3 deletions
  1. 1 1
      frameworks/Zig/zzz/README.md
  2. 6 2
      frameworks/Zig/zzz/src/main.zig

+ 1 - 1
frameworks/Zig/zzz/README.md

@@ -1,5 +1,5 @@
 
 
-# [ZZZ](https://github.com/tardy-org/zzz) - Web Franework.
+# [ZZZ](https://github.com/tardy-org/zzz) - Web Framework.
 
 
 ## Description
 ## Description
 
 

+ 6 - 2
frameworks/Zig/zzz/src/main.zig

@@ -76,19 +76,23 @@ pub fn main() !void {
 }
 }
 
 
 pub fn home_handler(ctx: *const Context, _: void) !Respond {
 pub fn home_handler(ctx: *const Context, _: void) !Respond {
-    try ctx.response.headers.put("Date", try ctx.allocator.dupe(u8, date[0..]));
     return ctx.response.apply(.{
     return ctx.response.apply(.{
         .mime = http.Mime.TEXT,
         .mime = http.Mime.TEXT,
         .body = "Hello, World!",
         .body = "Hello, World!",
         .status = .OK,
         .status = .OK,
+        .headers = &.{
+           .{"Date", try ctx.allocator.dupe(u8, date[0..])},
+        },
     });
     });
 }
 }
 
 
 pub fn json_handler(ctx: *const Context, _: void) !Respond {
 pub fn json_handler(ctx: *const Context, _: void) !Respond {
-    try ctx.response.headers.put("Date", try ctx.allocator.dupe(u8, date[0..]));
     return ctx.response.apply(.{
     return ctx.response.apply(.{
         .mime = http.Mime.JSON,
         .mime = http.Mime.JSON,
         .body = try std.json.stringifyAlloc(ctx.allocator, Message{ .message = "Hello, World!" }, .{}),
         .body = try std.json.stringifyAlloc(ctx.allocator, Message{ .message = "Hello, World!" }, .{}),
         .status = .OK,
         .status = .OK,
+        .headers = &.{
+            .{"Date", try ctx.allocator.dupe(u8, date[0..])},
+        },
     });
     });
 }
 }