Skip to content

Commit

Permalink
Merge pull request satoshi-takano#38 from mikhailbasbas/master
Browse files Browse the repository at this point in the history
Added return value URLSessionDataTask for OpenGraph.fetch
  • Loading branch information
satoshi-takano authored Jan 27, 2020
2 parents 93d8393 + 0170d49 commit bc29a05
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion OpenGraph/OpenGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ public struct OpenGraph {

public let source: [OpenGraphMetadata: String]

public static func fetch(url: URL, headers: [String: String]? = nil, completion: @escaping (Result<OpenGraph, Error>) -> Void) {
@discardableResult
public static func fetch(url: URL, headers: [String: String]? = nil, completion: @escaping (Result<OpenGraph, Error>) -> Void) -> URLSessionDataTask {
var mutableURLRequest = URLRequest(url: url)
headers?.compactMapValues { $0 }.forEach {
mutableURLRequest.setValue($1, forHTTPHeaderField: $0)
Expand All @@ -19,6 +20,7 @@ public struct OpenGraph {
}
})
task.resume()
return task
}

private static func handleFetchResult(data: Data?, response: URLResponse?, completion: @escaping (Result<OpenGraph, Error>) -> Void) {
Expand Down

0 comments on commit bc29a05

Please sign in to comment.