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

Code before:
extension Container {
    /// Creates a `Client` for this `Container`.
    ///
    ///     let res = try req.client().get("http://vapor.codes")
    ///     print(res) // Future<Response>
    ///
    /// See `Client` for more information.
    public func client() throws -> Client {
        return try make()
    }
}

/// Connects to remote HTTP servers and sends HTTP requests receiving HTTP responses.
///
///     let res = try req.client().get("http://vapor.codes")
///     print(res) // Future<Response>
///
public protocol Client {
    /// The `Container` to use for creating `Request`s.
    var container: Container! { get }

    /// Sends an HTTP `Request` to a server.
    ///
    ///     let req: Request ...
    ///     let res = try client.send(req)
    ///     print(res) // Future<Response>
    ///
    /// - parameters:
    ///     - request: `Request` to send.
    /// - returns: A `Future` containing the requested `Response` or an `Error`.
    func send(_ req: Request) -> Future<Response>
}

extension Client {
    /// Sends an HTTP `GET` `Request` to a server with an optional configuration closure that will run before sending.
    ///
    ///     let res = try client.get("http://api.vapor.codes/users")
    ///     print(res) // Future<Response>
    ///
    /// HTTP `GET` requests are typically used for fetching information and do not have bodies.
    /// However, the `beforeSend` closure is a great place for encoding query string parameters.
    ///
    ///     let res = try client.get("http://api.vapor.codes/users") { get in
    ///         try get.query.encode(["name": "vapor"])
    ///     }

Review comment (suggestion):
I personally reall (REALLY) dislike having to put the `!` here, but it was the only way I could think of not making everyone use optional-chaining everywhere, since it's required to make this `weak`

Code after:
extension Container {
    /// Creates a `Client` for this `Container`.
    ///
    ///     let res = try req.client().get("http://vapor.codes")
    ///     print(res) // Future<Response>
    ///
    /// See `Client` for more information.
    public func client() throws -> Client {
        return try make()
    }
}

/// Connects to remote HTTP servers and sends HTTP requests receiving HTTP responses.
///
///     let res = try req.client().get("http://vapor.codes")
///     print(res) // Future<Response>
///
public protocol Client {
    /// The `Container` to use for creating `Request`s.
    var container: Container { get }

    /// Sends an HTTP `Request` to a server.
    ///
    ///     let req: Request ...
    ///     let res = try client.send(req)
    ///     print(res) // Future<Response>
    ///
    /// - parameters:
    ///     - request: `Request` to send.
    /// - returns: A `Future` containing the requested `Response` or an `Error`.
    func send(_ req: Request) -> Future<Response>
}

extension Client {
    /// Sends an HTTP `GET` `Request` to a server with an optional configuration closure that will run before sending.
    ///
    ///     let res = try client.get("http://api.vapor.codes/users")
    ///     print(res) // Future<Response>
    ///
    /// HTTP `GET` requests are typically used for fetching information and do not have bodies.
    /// However, the `beforeSend` closure is a great place for encoding query string parameters.
    ///
    ///     let res = try client.get("http://api.vapor.codes/users") { get in
    ///         try get.query.encode(["name": "vapor"])
    ///     }