AlamoFire, похоже, ничего не делает
Я пытаюсь написать простой скребок с AlamoFire для серверной части Vapor. AlamoFire, кажется, инициирован правильно, но я не получаю никаких действий от обработчика обратного вызова.
import Routing
import Vapor
import Alamofire
public func routes(_ router: Router) throws {
router.get("scrape") { req -> String in
let stuff = Stuff(id: nil, sourcecode: "This saves to the database.")
stuff.save(on: req)
let q = Alamofire.request("http://sigh-fi.com/test.txt").responseString { response in
// None of this prints to the terminal.
print("Success: \(response.result.isSuccess)")
print("Request: \(String(describing: response.response))")
print("Result: \(String(describing: response.result))")
print("String: \(String(describing: response.result.value))")
// ideally I'd like to run...
// let morestuff = Stuff(id: nil, sourcecode: response.result.value)
let morestuff = Stuff(id: nil, sourcecode: "This doesn't save to the database, so I'm not even getting that far.")
morestuff.save(on: req)
}
print(q) // prints "GET http://sigh-fi.com/test.txt" as expected
return "okay"
}
}
К сожалению, я не могу сказать, является ли это проблемой Vapor, Alamofire или Swift. Любые предложения будут ценны.
1 ответ
Решение
Получается, что у Vapor есть своя собственная клиентская библиотека HTTP, и, похоже, она работает нормально. До сих пор не уверены, почему Alamofire развалился, но это спорный вопрос.
Спасибо за помощь, Ник.