1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-20 23:24:09 +00:00

nicer way of creating authenticator, auth endpoint

This commit is contained in:
Rene Schallner 2023-04-16 20:13:39 +02:00
parent 1ffe01dc7a
commit 208a443685

View file

@ -164,11 +164,13 @@ test "BearerAuthSingle authenticateRequest" {
var ep = Endpoints.SimpleEndpoint.init(.{ .path = "/test", .get = endpoint_http_get }); var ep = Endpoints.SimpleEndpoint.init(.{ .path = "/test", .get = endpoint_http_get });
// create authenticator // create authenticator
var authenticator = try Authenticators.BearerAuthSingle.init(a, token, null); const Authenticator = Authenticators.BearerAuthSingle;
var authenticator = try Authenticator.init(a, token, null);
defer authenticator.deinit(); defer authenticator.deinit();
// create authenticating endpoint // create authenticating endpoint
var auth_ep = Endpoints.AuthenticatingEndpoint(@TypeOf(authenticator)).init(&ep, &authenticator); const BearerAuthEndpoint = Endpoints.AuthenticatingEndpoint(Authenticator);
var auth_ep = BearerAuthEndpoint.init(&ep, &authenticator);
try listener.addEndpoint(auth_ep.getEndpoint()); try listener.addEndpoint(auth_ep.getEndpoint());