File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Sources/Lemmy-Swift-Client Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -12,10 +12,7 @@ public class LemmyAPI {
1212 self . urlSession = urlSession
1313 }
1414
15- /// Do request to lemmy server and return URLSession result
16- public func baseRequest< T: APIRequest > ( _ apiRequest: T ) async throws
17- -> ( T . Response , URLResponse , Data )
18- {
15+ public func urlRequest< T: APIRequest > ( _ apiRequest: T ) throws -> URLRequest {
1916 var request = URLRequest ( url: baseUrl. appending ( path: T . path) )
2017 request. httpMethod = T . httpMethod. rawValue
2118 let encoder = JSONEncoder ( )
@@ -32,6 +29,14 @@ public class LemmyAPI {
3229 request. httpBody = try encoder. encode ( apiRequest)
3330 }
3431 request. setValue ( " application/json " , forHTTPHeaderField: " Content-Type " )
32+ return request
33+ }
34+
35+ /// Do request to lemmy server and return URLSession result
36+ public func baseRequest< T: APIRequest > ( _ apiRequest: T ) async throws
37+ -> ( T . Response , URLResponse , Data )
38+ {
39+ let request = try urlRequest ( apiRequest)
3540 let ( data, response) = try await URLSession . shared. data ( for: request)
3641 let decoder = JSONDecoder ( )
3742 let decodedResult = try decoder. decode ( T . Response. self, from: data)
You can’t perform that action at this time.
0 commit comments