func add(_ collection: RouteCollection, csrf: Bool = true, login: Bool = true) throws { var middlewares: [Middleware] = [] if csrf { middlewares.append(csrfProtection.middleware) } if login { middlewares += userLoginGuard(doesRedirect: true) } try routes.group(middlewares) { (routes) in try routes.register(collection: collection) } }