Repository: vapor/vapor
File: Sources/Vapor/Routing/Router+Method.swift (Swift)

Code before:
import Routing

/// Capable of registering async routes.
extension Router {
    /// Registers a route handler at the supplied path.
    @discardableResult
    public func on<T>(
        _ method: HTTPMethod,
        to path: [PathComponent],
        use closure: @escaping RouteResponder<T>.Closure
    ) -> Route<Responder> where T: ResponseEncodable {
        let responder = RouteResponder(closure: closure)
        let route = Route<Responder>(
            path: [.constants([.bytes(method.bytes)])] + path,
            output: responder
        )
        self.register(route: route)
        return route
    }
    
    /// Registers a route handler at the supplied path.
    @discardableResult
    fileprivate func on<C, T>(
        _ method: HTTPMethod,
        to path: [PathComponent],
        use closure: @escaping ContentRouteResponder<C, T>.Closure
    ) -> Route<Responder> where C: RequestDecodable, T: ResponseEncodable {
        let responder = ContentRouteResponder(closure: closure)
        let route = Route<Responder>(
            path: [.constants([.bytes(method.bytes)])] + path,
            output: responder
        )
        self.register(route: route)
        return route
    }
}

extension Future: ResponseEncodable where T: ResponseEncodable {
    /// See ResponseEncodable.encode
    public func encode(for req: Request) throws -> Future<Response> {
        return flatMap(to: Response.self) { exp in
            try exp.encode(for: req)
        }
    }
}

extension Router {
    /// Creates a `Route` at the provided path using the `GET` method.
    ///
    /// [Learn More →](https://docs.vapor.codes/3.0/getting-started/routing/)

Review comment (suggestion):
inconsistent labels (`to:` vs `path:` on the other calls). IMO this should be `at:` to match what we do in other parts of the framework, like in CodableKit 

Code after:
import Routing

/// Capable of registering async routes.
extension Router {
    /// Registers a route handler at the supplied path.
    @discardableResult
    public func on<T>(
        _ method: HTTPMethod,
        at path: [PathComponent],
        use closure: @escaping RouteResponder<T>.Closure
    ) -> Route<Responder> where T: ResponseEncodable {
        let responder = RouteResponder(closure: closure)
        let route = Route<Responder>(
            path: [.constants([.bytes(method.bytes)])] + path,
            output: responder
        )
        self.register(route: route)
        return route
    }
    
    /// Registers a route handler at the supplied path.
    @discardableResult
    fileprivate func on<C, T>(
        _ method: HTTPMethod,
        at path: [PathComponent],
        use closure: @escaping RequestDecodableResponder<C, T>.Closure
    ) -> Route<Responder> where C: RequestDecodable, T: ResponseEncodable {
        let responder = RequestDecodableResponder(closure: closure)
        let route = Route<Responder>(
            path: [.constants([.bytes(method.bytes)])] + path,
            output: responder
        )
        self.register(route: route)
        return route
    }
}

extension Future: ResponseEncodable where T: ResponseEncodable {
    /// See ResponseEncodable.encode
    public func encode(for req: Request) throws -> Future<Response> {
        return flatMap(to: Response.self) { exp in
            try exp.encode(for: req)
        }
    }
}

extension Router {
    /// Creates a `Route` at the provided path using the `GET` method.
    ///
    /// [Learn More →](https://docs.vapor.codes/3.0/getting-started/routing/)