Skip to content

Commit

Permalink
added support for vapor 3.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
AAAstorga committed May 7, 2018
1 parent 315dac7 commit ef2ee8a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let package = Package(
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/vapor/vapor.git", from: "3.0.0-rc.2.7"),
.package(url: "https://github.com/vapor/vapor.git", from: "3.0.1"),
.package(url: "https://github.com/vapor/jwt.git", from: "3.0.0-rc.2.1.1")
],
targets: [
Expand Down
8 changes: 4 additions & 4 deletions Sources/Ferno/FernoRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ public class FernoAPIRequest: FernoRequest {

public func delete(req: Request, method: HTTPMethod, path: [String]) throws -> Future<Bool> {
return try self.createRequest(method: method, path: path, query: [], body: "", headers: [:]).flatMap({ request in
return try self.httpClient.respond(to: request).map({ response in
return self.httpClient.send(request).map({ response in
return response.http.status == .ok
})
})
}

public func send<F: Decodable, T: Content>(req: Request, method: HTTPMethod, path: [String], query: [FernoQuery], body: T, headers: HTTPHeaders) throws -> Future<F> {
return try self.createRequest(method: method, path: path, query: query, body: body, headers: headers).flatMap({ (request) in
return try self.httpClient.respond(to: request).flatMap(to: F.self) { response in
return self.httpClient.send(request).flatMap(to: F.self) { response in
guard response.http.status == .ok else { throw FernoError.requestFailed }
return try self.decoder.decode(F.self, from: response.http, maxSize: 65_536, on: req)
}
Expand All @@ -56,7 +56,7 @@ public class FernoAPIRequest: FernoRequest {

public func sendMany<F: Decodable, T: Content>(req: Request, method: HTTPMethod, path: [String], query: [FernoQuery], body: T, headers: HTTPHeaders) throws -> Future<[String: F]> {
return try self.createRequest(method: method, path: path, query: query, body: body, headers: headers).flatMap({ (request) in
return try self.httpClient.respond(to: request).flatMap(to: [String: F].self) { response in
return self.httpClient.send(request).flatMap(to: [String: F].self) { response in
guard response.http.status == .ok else { throw FernoError.requestFailed }
return try self.decoder.decode(Snapshot<F>.self, from: response.http, maxSize: 65_536, on: req).map { snapshot in
return snapshot.data
Expand Down Expand Up @@ -109,7 +109,7 @@ extension FernoAPIRequest {
try req.content.encode(oauthBody, as: .urlEncodedForm)
req.http.url = URL(string: "https://www.googleapis.com/oauth2/v4/token")!
req.http.method = .POST
return try self.httpClient.respond(to: req).flatMap(to: OAuthResponse.self) { result in
return self.httpClient.send(req).flatMap(to: OAuthResponse.self) { result in
let oauthRes: Future<OAuthResponse> = try result.content.decode(OAuthResponse.self)
return oauthRes
}.map(to: String.self) { resp in
Expand Down

0 comments on commit ef2ee8a

Please sign in to comment.