Skip to content

Commit

Permalink
Query items
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseidhof committed Jun 11, 2019
1 parent 0e01ca7 commit a96b073
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Sources/TinyNetworking/RemoteEndpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public struct Endpoint<A> {

public init(_ method: Method, url: URL, accept: ContentType? = nil, contentType: ContentType? = nil, body: Data? = nil, headers: [String:String] = [:], expectedStatusCode: @escaping (Int) -> Bool, timeOutInterval: TimeInterval = 10, query: [String:String] = [:], parse: @escaping (Data?) -> Result<A, Error>) {
var comps = URLComponents(string: url.absoluteString)!
comps.queryItems = query.map { URLQueryItem(name: $0.0, value: $0.1) }
comps.queryItems = comps.queryItems ?? []
comps.queryItems!.append(contentsOf: query.map { URLQueryItem(name: $0.0, value: $0.1) })
request = URLRequest(url: comps.url!)
if let a = accept {
request.setValue(a.rawValue, forHTTPHeaderField: "Accept")
Expand Down

0 comments on commit a96b073

Please sign in to comment.