Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Sources/SimpleHTTP/Session/Session.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class Session {
///
/// The request is validated and decoded appropriately on success.
/// - Returns: a async Output on success, an error otherwise
@concurrent
public func response<Output: Decodable>(for request: Request<Output>) async throws -> Output {
let result = try await dataPublisher(for: request)

Expand All @@ -62,6 +63,7 @@ public class Session {
}

/// Perform asynchronously `request` which has no return value
@concurrent
public func response(for request: Request<Void>) async throws {
let result = try await dataPublisher(for: request)
log(.success(()), for: result.request)
Expand Down
7 changes: 1 addition & 6 deletions Sources/SimpleHTTP/Session/SessionConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import Foundation
public struct SessionConfiguration {
/// data encoders/decoders configuration per content type
let data: ContentDataCodersConfiguration
/// queue on which to decode data
let decodingQueue: DispatchQueue
/// an interceptor to apply custom behavior on the session requests/responses.
/// To apply multiple interceptors use `ComposeInterceptor`
let interceptor: Interceptor
Expand All @@ -17,21 +15,18 @@ public struct SessionConfiguration {
/// - Parameter interceptors: interceptor list to apply on the session requests/responses
public init(
data: ContentDataCodersConfiguration = .init(),
decodingQueue: DispatchQueue = .main,
interceptors: CompositeInterceptor = []) {
self.data = data
self.decodingQueue = decodingQueue
self.interceptor = interceptors
}

/// - Parameter dataError: Error type to use when having error with data
public init<DataError: Error & Decodable>(
data: ContentDataCodersConfiguration,
decodingQueue: DispatchQueue = .main,
interceptors: CompositeInterceptor = [],
dataError: DataError.Type
) {
self.init(data: data, decodingQueue: decodingQueue, interceptors: interceptors)
self.init(data: data, interceptors: interceptors)
self.errorConverter = { [decoders=data.decoders] data, contentType in
guard let decoder = decoders[contentType] else {
throw SessionConfigurationError.missingDecoder(contentType)
Expand Down
Loading