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

Code before:
public protocol Client {
    var eventLoop: EventLoop { get }
    func delegating(to eventLoop: EventLoop) -> Client
    func delegating(to eventLoop: EventLoop, logger: Logger) -> Client
    func send(_ request: ClientRequest) -> EventLoopFuture<ClientResponse>
}

extension Client {
    func delegating(to eventLoop: EventLoop, logger: Logger) -> Client {
        return self.delegating(to: eventLoop)
    }
}

extension Client {
    public func get(_ url: URI, headers: HTTPHeaders = [:], beforeSend: (inout ClientRequest) throws -> () = { _ in }) -> EventLoopFuture<ClientResponse> {
        return self.send(.GET, headers: headers, to: url, beforeSend: beforeSend)
    }

    public func post(_ url: URI, headers: HTTPHeaders = [:], beforeSend: (inout ClientRequest) throws -> () = { _ in }) -> EventLoopFuture<ClientResponse> {
        return self.send(.POST, headers: headers, to: url, beforeSend: beforeSend)
    }

    public func patch(_ url: URI, headers: HTTPHeaders = [:], beforeSend: (inout ClientRequest) throws -> () = { _ in }) -> EventLoopFuture<ClientResponse> {
        return self.send(.PATCH, headers: headers, to: url, beforeSend: beforeSend)
    }

    public func put(_ url: URI, headers: HTTPHeaders = [:], beforeSend: (inout ClientRequest) throws -> () = { _ in }) -> EventLoopFuture<ClientResponse> {
        return self.send(.PUT, headers: headers, to: url, beforeSend: beforeSend)
    }

Review comment (suggestion):
I'd prefer having a separate `logging(to:)` method since that's what other Vapor packages do. It doesn't need to be mutating as it can return a copy. `Client` should be able to provide a default implementation of `logging(to:)` that either does nothing or fatals saying the client doesn't support overriding the logger. 

Code after:
public protocol Client {
    var eventLoop: EventLoop { get }
    func delegating(to eventLoop: EventLoop) -> Client
    func logging(to logger: Logger) -> Client
    func send(_ request: ClientRequest) -> EventLoopFuture<ClientResponse>
}

extension Client {
    public func logging(to logger: Logger) -> Client {
        return self
    }
}

extension Client {
    public func get(_ url: URI, headers: HTTPHeaders = [:], beforeSend: (inout ClientRequest) throws -> () = { _ in }) -> EventLoopFuture<ClientResponse> {
        return self.send(.GET, headers: headers, to: url, beforeSend: beforeSend)
    }

    public func post(_ url: URI, headers: HTTPHeaders = [:], beforeSend: (inout ClientRequest) throws -> () = { _ in }) -> EventLoopFuture<ClientResponse> {
        return self.send(.POST, headers: headers, to: url, beforeSend: beforeSend)
    }

    public func patch(_ url: URI, headers: HTTPHeaders = [:], beforeSend: (inout ClientRequest) throws -> () = { _ in }) -> EventLoopFuture<ClientResponse> {
        return self.send(.PATCH, headers: headers, to: url, beforeSend: beforeSend)
    }

    public func put(_ url: URI, headers: HTTPHeaders = [:], beforeSend: (inout ClientRequest) throws -> () = { _ in }) -> EventLoopFuture<ClientResponse> {
        return self.send(.PUT, headers: headers, to: url, beforeSend: beforeSend)
    }