File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55// Created by Maxim Ivanov on 27.10.2022.
66//
77
8+ import SwiftUI
89import UIKit
910
1011public protocol ViewBuilder {
@@ -35,3 +36,9 @@ public protocol SearchControllerBuilder {
3536
3637 func build( ) -> UISearchController
3738}
39+
40+ public protocol SwiftViewBuilder {
41+ associatedtype ViewType : View
42+
43+ func build( ) -> ViewType
44+ }
Original file line number Diff line number Diff line change 1+ //
2+ // LoggableHttpClient.swift
3+ // CoreModule
4+ //
5+ // Created by Maksim Ivanov on 06.05.2023.
6+ //
7+
8+ public final class LoggableHttpClient : HttpClient {
9+
10+ private let httpClient : HttpClient
11+ private let logger : Logger
12+
13+ public init ( httpClient: HttpClient = HttpClientImpl ( ) , logger: Logger ) {
14+ self . httpClient = httpClient
15+ self . logger = logger
16+ }
17+
18+ public func send( _ http: Http ) -> RxHttpResponse {
19+ logger. log ( " HTTP REQUEST START: \( http) " , level: . info)
20+
21+ return httpClient. send ( http)
22+ . handleEvents (
23+ receiveOutput: { httpResponse in
24+ self . logger. log (
25+ """
26+ HTTP RESPONSE FETCHED
27+ HTTPURLResponse: \( httpResponse. response)
28+ Data: \( String ( decoding: httpResponse. data, as: UTF8 . self) )
29+ """ ,
30+ level: . info
31+ )
32+ } ,
33+ receiveCompletion: { completion in
34+ switch completion {
35+ case . failure( let error) :
36+ self . logger. log ( " HTTP REQUEST ERROR: \( error) " , level: . error)
37+
38+ default :
39+ break
40+ }
41+ }
42+ )
43+ . eraseToAnyPublisher ( )
44+ }
45+ }
You can’t perform that action at this time.
0 commit comments