Repository: vapor/vapor
File: Sources/Vapor/Routing/RoutingGroups.swift (Swift)

Code before:
    ///     .grouped(using: AuthorizationMiddleware)
    ///     .grouped(using: userMustBeCurrentUser)
    ///
    /// // adding "user/profile/" route to router
    /// // both of validations applied
    /// users.get("auth", use: userAuthHandler)
    ///
    /// ```
    ///
    /// [Learn More →](https://docs.vapor.codes/3.0/vapor/route-group/#path-components)
    ///
    /// - Parameter middleware: Middleware
    /// - Returns: RouterGroup with middleware attached
    public func grouped(using middleware: Middleware...) -> RouteGroup {
        return RouteGroup(cascadingTo: self, middleware: middleware)
    }
    
    
    /// Returns a RouteGroup cascading to router with middleware attached
    ///
    /// **Example:**
    /// ```
    /// let userMustBeAuthorized = AuthorizationMiddleware()
    ///
    /// // creating new group on router
    /// router.group(using: AuthorizationMiddleware) { group in
    ///
    ///         // adding "user/profile/" route to router
    ///         // AuthorizationMiddleware is applied
    ///         group.get("profile", use: userProfileHandler)
    ///     }
    /// ```
    ///
    /// [Learn More →](https://docs.vapor.codes/3.0/vapor/route-group/#path-components)
    /// - Parameters:
    ///   - middleware: Middleware
    ///   - configure: Group configuration function
    ///
    public func group(using middleware: Middleware..., configure: (RouteGroup) -> ()) {
        configure(RouteGroup(cascadingTo: self, middleware: middleware))
    }
    
    // MARK: - Add using of middleware pure functions
    
    /// Returns a group cascading to router with function attached
    ///
    ///
    /// **Example:**
    /// ```
    /// let userMustBeAuthorized = { req, next in
    ///     return try userService.authorized(user)

Review comment (security):
This either needs to be `using: userMustBeAuthorized` or `using: AuthorizationMiddleware.self` I would have thought

Code after:
    ///     // adding "user/auth/" route to router
    ///     group.get("auth", use: userAuthHandler)
    ///
    ///     // adding "user/profile/" route to router
    ///     group.get("profile", use: userProfileHandler)
    /// }
    ///
    /// ```
    ///
    /// [Learn More →](https://docs.vapor.codes/3.0/vapor/route-group/#path-components)
    ///
    /// - Parameter path: Group path components separated by commas
    /// - Returns: created RouteGroup
    public func group(with path: PathComponent..., configure: (RouteGroup) -> ()) {
        configure(RouteGroup(cascadingTo: self, components: path))
    }
    
    
    // MARK: - Add using of middleware
    
    /// Returns a RouteGroup cascading to router with middleware attached
    ///
    /// **Example:**
    /// ```
    /// let userMustBeAuthorized = AuthorizationMiddleware(....)
    /// let userMustBeCurrentUser = CheckIfCurrentUserMiddleware(....)
    ///
    /// // then creating new group on router
    /// let users = router.grouped("user")
    ///     .grouped(using: userMustBeAuthorized)
    ///     .grouped(using: userMustBeCurrentUser)
    ///
    /// // adding "user/profile/" route to router
    /// // both of validations applied
    /// users.get("profile", use: userProfileHandler)
    ///
    /// ```
    ///
    /// [Learn More →](https://docs.vapor.codes/3.0/vapor/route-group/#path-components)
    ///
    /// - Parameter middleware: Middleware
    /// - Returns: RouterGroup with middleware attached
    public func grouped(using middleware: Middleware...) -> RouteGroup {
        return RouteGroup(cascadingTo: self, middleware: middleware)
    }
    
    
    /// Returns a RouteGroup cascading to router with middleware attached
    ///
    /// **Example:**
    /// ```