6 ms·
Alamofire: HTTP Networking in Swift
- matttthompson 12y agoCreator of Alamofire here. Just pushed the 1.0.0 release. Happy to answer any questions you might have.
- mythz 12y agoLooks like a great lib with a nice API, thx. Was there any reason why you chose callbacks over a Promise-like pattern for the async responses? Also do you know of any good HTTP Server libraries that will let you develop simple HTTP JSON services in Swift?
- wahnfrieden 12y agoSee Moya for a lib built on top of AlamoFire that adds reactive signals (fulfilling the promises use case): https://github.com/AshFurrow/Moya https://github.com/AshFurrow/Moya
- matttthompson 12y ago> Was there any reason why you chose callbacks over a Promise-like pattern for the async responses? Deeply-nested networking callbacks are a code smell, and I find that promises often do more harm by hiding those smells—or worse, obscuring the flow itself. In practice, Alamofire is mostly going to be single or at most nested two levels deep anyway.
- myko 12y agoIn the README it looks like using the ObjC AFNetworking is suggested if one wishes to do multipart http requests, I assume this is up to date and Alamofire doesn't support this at this time?
- matttthompson 12y agoYes, that's correct.
- Void_ 12y agoIs there any way to add custom HTTP header yet? This would make for a nice API: Alamofire.request(.GET, "http://httpbin.org/get") .header("custom-header", "value")
- matttthompson 12y agoThe short answer: Use the version of `request` that takes a `URLRequestConvertible`, and specify the header fields in that. The long answer: Custom headers on a per-request basis are a bit of a red herring, from an API design perspective. In reality, most use cases boil down to one of three, which are taken care of in other ways: - Default headers, such as `User-Agent`, are specified in `NSURLSessionConfiguration -HTTPAdditionalHeaders`. - `Authorization` headers, which are handled by `NSURLCredential` and `NSURLAuthenticationChallenge`. - `Content-Type` headers, which are handled by `ParameterEncoding`. This is why Alamofire is designed the way it is.
- ksylvest 12y agoAwesome!
- inglor 12y agoWhat about supporting using something like PromiseKit for error handling and interoperability with aggregation methods? Would you be willing to consider that? Thanks for your work by the way.
- matttthompson 12y agoI don't really see much need for it. Others are welcome to create such an integration, but I probably won't do so myself.
- inglor 12y agoAggregation of multiple requests with centralized error handling would be really nice, I guess that could be built from the outside though.
- qrush 12y agoHey Matt! A few: * Is this being used in any apps in the App Store currently by you? (or Panic?) * Is Alamofire a non-profit or some kind of organization? Curious why it's listed in the README. * Perhaps a bit deeper: Why a rewrite of AFNetworking's feature set instead of a AFN 3.0?
- jtokoph 12y agoAre all of Alamofire/PackRat/Gowalla defunct now?
- spacecadet 12y agoI wondered this too.
- treve 12y agoCongrats on this release! However, I think the library name is a bit of a poor choice. I don't want to take away your thunder, I just picked this post to do my rant :). There seems to be a lot of new general-purpose libraries with very poor non-descriptive names coming out. Whenever I need to dive into a new codebase, in a language and ecosystem I'm unfamiliar with, it's extremely hard to figure out which dependency and library does what. I was tasked to dive into a massive RoR application recently, and I ended up having to write a glossary first to remember what every non-descriptive noun implied. After getting familiar with a particular language's ecosystem, this problem becomes tends to go away, and as a library writer, it becomes easier to fall into the same trap by picking a name that's marketable and distinct. But I feel we're collectively making it increasingly harder for people to ramp up in new ecosystems and maintain future legacy codebases. For names of large applications this is not as bad, and some of these applications become household names, but I think we should try to avoid this for general-purpose utilities.
- krschultz 12y agoThe alternative is non-memorable names. I can't tell you how many android-async-image-loader libraries there are. It's a lot easier to remember 'Picasso'. It's also a lot easier for me to Google for 'Picasso Android' and get relevant results.
- treve 12y agoA better alternative is a combination of both, such as : [fancynoun-purpose]. For example: alamo-http
- altyus 12y agoI think Mattt can get away with this as he has the most well known open source library for cocoa development.
- treve 12y agoI'm not a cocoa developer, and I don't really know who matt is, or what library that may be ;). Once I'm a seated cocoa developer I probably will though, but then my general point no longer really applies.
- perishabledave 12y agoThanks for all your work! Been using AFNetworking for years and Alamofire looks great. So... what do those guys at Panic have you working on? ;)
- ardfard 12y agoThanks for your great works! I am using Alamofire on my project right now. Do Alamofire support or will support async image loading via URL just like AFNetworking? I can't find the API anywhere on the docs.