Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Commit

Permalink
Add trys
Browse files Browse the repository at this point in the history
  • Loading branch information
siemensikkema committed Oct 23, 2020
1 parent 93ce1c3 commit 733ea85
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Sources/JWTKeychain/Extensions/Router.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,31 @@ public extension Router {
on container: Container
) throws {
let config: JWTKeychainConfig<U> = try container.make()
let controller = config.controller
let middlewares: JWTKeychainMiddlewares<U> = try container.make()
let access = self.grouped(middlewares.accessMiddlewares)

if let registerPath = config.endpoints.register {
self.post(registerPath) { req in config.controller.register(req: req) }
self.post(registerPath) { req in try controller.register(req: req) }
}

if let loginPath = config.endpoints.login {
self.post(loginPath) { req in config.controller.logIn(req: req) }
self.post(loginPath) { req in try controller.logIn(req: req) }
}

if let mePath = config.endpoints.me {
access.get(mePath) { req in config.controller.me(req: req) }
access.get(mePath) { req in try controller.me(req: req) }
}

if let updatePath = config.endpoints.update {
access.patch(updatePath) { req in config.controller.update(req: req) }
access.patch(updatePath) { req in try controller.update(req: req) }
}

if
let refreshMiddlewares = middlewares.refreshMiddlewares,
let tokenPath = config.endpoints.token
{
self.grouped(refreshMiddlewares).post(tokenPath) { req in config.controller.token(req: req) }
self.grouped(refreshMiddlewares).post(tokenPath) { req in try config.controller.token(req: req) }
}
}
}

0 comments on commit 733ea85

Please sign in to comment.