TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Jan 2017 |
Maintained by Softwind Tang.
A lite api framework that implemented basic RPC reqirements. We use chaining coding style to provide convenience of calling methods. We have covered most situations of http/https request between iOS client and your backend.
willStart
and didFinish
.
- (void)createYourAPITemplate {
[LA createTemplate:^(LARequestMaker *maker) {
maker.host(@"http://your-host").version(@"v1").method(LAMethodGET);
maker.post(LAPostStyleForm).sync(NO).response(LAResponseStyleJSON);
maker.willStart.delegate(self, @selector(sign:));
}
withIdentifier:@"template"
onStatus:LAStatusProduction];
}
- (NSURLRequest *)sign:(NSMutableURLRequest *)request {
//do your sign
return request;
}
- (void)invokeYourAPI {
[LA invokeRequest:^(LARequestMaker *maker) {
maker.import(@"template").path(@"/ping");
maker.didFinish.thread(LAThreadBackground).block(^id(LAResponse *response){
NSLog(@"%@", response.JSON);
return nil;
});
}];
}
or you may not want to use block:
- (void)invokeYourAPI {
[LA invokeRequest:^(LARequestMaker *maker) {
maker.import(@"template").path(@"/ping");
maker.didFinish.thread(LAThreadBackground).delegate(self, @selector(didFinish:));
}];
}
- (id)didFinish:(LAResponse *)response {
//do your business
return nil;
}
- (void)example {
[LA createTemplate:^(LARequestMaker *maker) {
maker.import(@"template").host(@"http://your-beta-host");
}
withIdentifier:@"template"
onStatus:LAStatusBeta];
[LA switchStatusTo:LAStatusBeta];
}