1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-21 07:34:08 +00:00

Update middleware example with direct context

This commit is contained in:
Ed Yu 2023-06-21 15:21:42 -07:00
parent 5611026479
commit cc0680d6e3

View file

@ -20,10 +20,10 @@ const SharedAllocator = struct {
}; };
// create a combined context struct // create a combined context struct
const Context = zap.Middleware.MixContexts(.{ const Context = struct {
.{ .name = "?user", .type = UserMiddleWare.User }, user: ?UserMiddleWare.User = null,
.{ .name = "?session", .type = SessionMiddleWare.Session }, session: ?SessionMiddleWare.Session = null,
}); };
// we create a Handler type based on our Context // we create a Handler type based on our Context
const Handler = zap.Middleware.Handler(Context); const Handler = zap.Middleware.Handler(Context);