OSRESTfulClient is a light-weight RESTful client for iOS APP. Inspired by Retrofit and Masonry. Support Http/2.
Making a request is very easy, just use the builder pattern:
OSRESTfulEndpoint *endpoint = [[OSRESTfulEndpoint alloc] initWithBaseURLString:@"https://api.github.com"];
OSRESTfulClient *client = [[OSRESTfulClient alloc] initWithEndpoint:endpoint
configuration:[NSURLSessionConfiguration defaultSessionConfiguration]];
BFTask *request = client.builder
.setPath(@"/repos")
.withGet
.buildArrayWithModel([OSRepo class])
.request;
Or path with parameters:
OSRESTfulEndpoint *endpoint = [[OSRESTfulEndpoint alloc] initWithBaseURLString:@"https://api.github.com"];
OSRESTfulClient *client = [[OSRESTfulClient alloc] initWithEndpoint:endpoint
configuration:[NSURLSessionConfiguration defaultSessionConfiguration]];
BFTask *request = client.builder
.setPath(@"/users/{user_id}/repos")
.setPathParams(@{@"user_id" : userId})
.withGet
.buildArrayWithModel([OSRepo class])
.request;
And get the result:
[request continueWithSuccessBlock:^id(BFTask *task) {
OSRepo *repo = task.result;
/* do something... */
return nil;
}];
You can take full advantage of Bolts: chaining task together, error handling, tasks in series, tasks in parallel, ...etc.
-
iOS7
- Bolts Framework (1.7.0)
- AFNetworking (3.1.0)
- Mantle (Default json decoder) (2.0.7)
OSRESTfulClient is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "OSRESTfulClient"
Kros Huang, kros@osolve.com
OSRESTfulClient is available under the MIT license. See the LICENSE file for more info.