We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bc75855 commit f9d48b0Copy full SHA for f9d48b0
examples/hello/greeter.zig
@@ -35,6 +35,13 @@ fn defaultHeaders(ctx: *zin.Context) !void {
35
try ctx.headers.append(.{ .name = "server", .value = "zin/v0.1.0" });
36
}
37
38
+fn auth(ctx: *zin.Context) !void {
39
+ const authorization = try ctx.getHeader("Authorization");
40
+ if (authorization.len == 0) {
41
+ try ctx.text(.unauthorized, "missing authorization header");
42
+ }
43
+}
44
+
45
pub fn main() !void {
46
var app = try zin.new(.{});
47
defer app.deinit();
@@ -43,6 +50,7 @@ pub fn main() !void {
50
try app.use(zin.mw.queryStringParser);
51
52
try app.use(defaultHeaders);
53
+ try app.use(auth);
54
55
// use classic route templating syntax to register handlers
48
56
try app.get("/greet/:name", greet);
0 commit comments