-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kamalifard, Mehran
committed
May 9, 2024
1 parent
60fec49
commit 1fe5722
Showing
13 changed files
with
77 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// | ||
// BaseAPIDebuger.swift | ||
// Amadeus | ||
// | ||
// Created by Mehran on 6/4/1401 AP. | ||
// | ||
|
||
import Foundation | ||
|
||
struct APIDebugger: Logging { | ||
|
||
func logRequest(request: URLRequest) { | ||
print("--- API Request ---") | ||
print("URL: \(request.url?.absoluteString ?? "N/A")") | ||
print("Method: \(request.httpMethod ?? "N/A")") | ||
if let headers = request.allHTTPHeaderFields { | ||
print("Headers:") | ||
for (key, value) in headers { | ||
print("\t\(key): \(value)") | ||
} | ||
} | ||
if let body = request.httpBody, let bodyString = String(data: body, encoding: .utf8) { | ||
print("Body:") | ||
print(bodyString) | ||
} | ||
print("-------------------") | ||
} | ||
|
||
func logResponse(response: URLResponse?, data: Data?) { | ||
guard let httpResponse = response as? HTTPURLResponse else { | ||
print("--- API Response ---") | ||
print("Invalid or no response received.") | ||
print("--------------------") | ||
return | ||
} | ||
|
||
print("--- API Response ---") | ||
print("Status Code: \(httpResponse.statusCode)") | ||
if let headers = httpResponse.allHeaderFields as? [String: String] { | ||
print("Headers:") | ||
for (key, value) in headers { | ||
print("\t\(key): \(value)") | ||
} | ||
} | ||
if let responseData = data, let responseString = String(data: responseData, encoding: .utf8) { | ||
print("Response Body:") | ||
print(responseString) | ||
} | ||
print("--------------------") | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters