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
let loggedUser = try await login.fetch(User.self) |
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
let result: HTTPResponse = try await req.fetch() |
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
let myObject = ... | |
req.body = .json(myObject) |
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
req.body = .multipart(boundary: nil, { | |
$0.add(string: "value", name: "param_1") | |
$0.add(fileURL: fileURL, name: "image", mimeType: .gif) | |
$0.add(string: "some other", name: "param_2") | |
}) |
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
req.headers[.contentType] = .bmp | |
req.headers = .init([ | |
.contentType: .bmp | |
"X-Custom-Header": "abc" | |
]) |
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
let req = HTTPRequest { | |
$0.url = URL(string: "https://.../login")! | |
$0.method = .post | |
$0.timeout = 15 | |
$0.redirectMode = redirect | |
$0.maxRetries = 4 | |
$0.headers = HTTPHeaders([ | |
.init(name: .userAgent, value: myAgent), | |
.init(name: "X-API-Experimental", value: "true") | |
]) |
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
let todo = try await HTTPRequest("https://jsonplaceholder.typicode.com/todos/1") | |
.fetch(Todo.self) |
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
public class MovieDBTest: XCTestCase { | |
/// The shared client with their settings. | |
private lazy var client: HTTPClient = { | |
client = HTTPClient(baseURL: "https://api.themoviedb.org/3") | |
// it will happens value to each call. | |
client.queryParams = [ | |
.init(name: "api_key", value: "<API KEY>"), | |
.init(name: "language", value: "IT-it") |
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
public class FFService { | |
// ... | |
private var flagsController: FlagsBrowserController | |
func showFlagsBrowser() { | |
flagsController = .create(loaders: [user, ...]) | |
mainController.present(flagsController, animated: true, completion: nil) | |
} | |
} |
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
struct UserExperiments: FlagCollectionProtocol { | |
@Flag(default: false, computedValue: MiscFlags.computedRememberLogin) | |
var rememberLogin: Bool | |
private static func computedRememberLogin() -> Bool? { | |
Language.main.code == "it" && allowsSSON == true | |
} | |
... |