Skip to content

Commit

Permalink
Allows discardableResult where output is Data
Browse files Browse the repository at this point in the history
Defaults headers and queries to String
  • Loading branch information
shaps80 committed Oct 12, 2022
1 parent 30648bc commit cfadef1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Sources/Endpoints/EndpointService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public extension EndpointService {
/// - domain: The `domain` associated with this endpoint
/// - body: The body data to include in the URLRequest
/// - Returns: The data and response returned for this endpoint request
@discardableResult
func perform<E>(_ endpoint: E) async throws -> (Data, HTTPURLResponse)
where E: EncodableEndpoint, E.Input == Data
{
Expand All @@ -136,6 +137,7 @@ public extension EndpointService {
/// - domain: The `domain` associated with this endpoint
/// - body: The encodable body to include in the URLRequest
/// - Returns: The data and response returned for this endpoint request
@discardableResult
func perform<E>(_ endpoint: E) async throws -> (Data, HTTPURLResponse)
where E: EncodableEndpoint
{
Expand All @@ -147,6 +149,7 @@ public extension EndpointService {
// MARK: Private

private extension EndpointService {
@discardableResult
func encode<E: EncodableEndpoint>(endpoint: E) throws -> Data {
do {
let result = try endpoint.encode()
Expand Down
2 changes: 1 addition & 1 deletion Sources/Endpoints/Models/Header.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

public protocol HeaderKey {
associatedtype Value: CustomStringConvertible
associatedtype Value: CustomStringConvertible = String
static var name: String { get }
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Endpoints/Models/Query.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation
import SwiftUI

public protocol QueryKey {
associatedtype Value: CustomStringConvertible
associatedtype Value: CustomStringConvertible = String
static var name: String { get }
}

Expand Down

0 comments on commit cfadef1

Please sign in to comment.