简体   繁体   中英

Which Framework/Package to use for Swift Linux that also can be used for Vapor

I've written an API-Wrapper for an external REST-API. This wrapper provides iOS and macOS-Apps an convenient access to that API. But I want to expand that API-Wrapper to Vapor on Linux. Linux (RaspiOS with 64-Bit) has Swift 5.5 running (without swift-corelibs-foundation ) so URLSession is not available. I tried SwiftyRequest and AsyncHTTPClient but both did not play well with Vapor. Eg wait() can't be used with Vapor and whenComplete() draws error * underlying error: uncleanShutdown* while syncShutdown can't be used for the same reason as wait()

So I'm stuck with connecting to the API. Can anyone recommend a HTTP-Client-Framework that works with Vapor on Linux?

Vapor has a Client protocol you should use if using Vapor but that's built on top of AsyncHTTPClient. You're correct in that you can't use wait() if you're on an event loop but you should use future handlers (or even better the new async/await APIs). What part is reporting unclean shutdown? If that's coming from AsyncHTTPClient then the API you're calling isn't closing the connection properly but you can configure it to ignore this.

As an aside, Vapor requires Foundation so you'll need that to be able to build it anyway

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM