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

Code before:
        return RouteGroup(cascadingTo: self, components: path)
    }
    
    /// Returns a RouteGroup cascading to router with middleware attached
    ///
    /// **Example:**
    /// ```
    /// let userMustBeAuthorized = AuthorizationMiddleware(....)
    /// let currentUser = CheckIfCurrentUserMiddleware(....)
    ///
    /// // creating new group on router
    /// let users = router.group("user")
    ///     .using(AuthorizationMiddleware)
    ///     .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 using(_ middleware: Middleware...) -> RouteGroup {
        return RouteGroup(cascadingTo: self, middleware: middleware)
    }
    
    /// Returns a group cascading to router with closure attached
    ///
    ///
    /// **Example:**
    /// ```
    /// let userMustBeAuthorized = { req, next in
    ///     return try userService.authorized(user)
    /// }
    ///
    /// let currentUser  = { req, next in
    ///     return try userService.isCurrentUser(req)
    /// }
    ///
    /// // creating new group on router
    /// let users = router.group("user")
    ///     .using(userMustBeAuthorized)
    ///     .using(userMustBeCurrentUser)
    ///
    /// // adding "user/profile/" route to router
    /// // both of validations applied
    /// users.get("auth", use: userAuthHandler)
    ///

Review comment (suggestion):
We should keep the `grouped` function name here for consistency. "using" would be better as a parameter label imo.

```swift
let users = router.grouped("users").grouped(using: MyMiddleware())
```

Code after:
        return self.super.route(request: request)
    }
}

extension Router {
    // MARK: - Create new group
    
    /// Creates a group cascading to router or group with the provided path components
    ///
    ///
    /// **Example:**
    /// ```
    /// // creating new group on router
    /// let users = router.grouped("user")
    ///
    /// // adding "user/auth/" route to router
    /// users.get("auth", use: userAuthHandler)
    ///
    /// // adding "user/profile/" route to router
    /// users.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 grouped(_ path: PathComponent...) -> RouteGroup {
        return RouteGroup(cascadingTo: self, components: path)
    }
    
    
    /// Creates a group cascading to router or group with the provided path components
    /// and use `configure` closure to configure crated group
    ///
    /// **Example:**
    /// ```
    /// // create new group and adds on router
    /// router.group(with: "user") { group in
    ///     // 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