'By Moya in Swift,how can I send a request with absolute url when already having baseURL?
Moya version: master integrated by GitHub
part of code sample:
enum Api {
case initialize(deviceName: String, upushDeviceToken: String)
case loadImage(_ url: String)
}
extension Api: TargetType {
var baseURL: URL {
URL(string: ApiKit.baseUrl)!
}
var path: String {
switch self {
case .initialize:
return "init"
case .loadImage(let url):
return "\(url)"
}
}
the loadImage request url is an absolute url like https://some-site/storage/image.png
When I tried loadImage, it combined basic url and the url, therefore server side return error 404
I guess it might have a solution of creating another TargetType to handle these absolute url requests, but I still want to know if there's a way to solve this in one TargetType.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
