1
0
Fork
You've already forked scarf
0
Non-blocking web server for Objective-C (OS X and iOS) http://niklaskorz.github.com/scarf/
  • Objective-C 97%
  • Ruby 3%
Find a file
2012年09月09日 11:58:01 +02:00
Scarf Added the code, library is already working, but more features will be implemented 2012年09月08日 21:43:58 +02:00
.gitignore Added podspec 2012年09月07日 20:46:16 +02:00
LICENSE Added license 2012年09月08日 10:34:55 +02:00
README.md Modified README 2012年09月09日 11:58:01 +02:00
scarf.podspec Added license URL to podspec 2012年09月08日 10:35:47 +02:00

Scarf is a non-blocking web server for Objective-C, supporting both OS X and iOS.

Dependencies:

  • Grand Central Dispatch (OS X 10.6 or newer, iOS 4.0 or newer)
  • New Objective-C literals (Clang 4.0 or newer)
  • CocoaAsyncSocket

License

Scarf uses the MIT license. See LICENSE for more information.

Simple Example

SCHTTPRequestHandler *indexHandler = [[SCHTTPRequestHandler alloc] init];
[indexHandler setHandlerBlock:^(SCHTTPRequest *request, SCHTTPResponse *response) {
 [response write:@"Hello World!"];
 return YES;
} forMethod:@"GET"];
NSDictionary *routes = @{
 @"/": indexHandler
};
SCHTTPServer *server = [[SCHTTPServer alloc] initWithRoutes:routes];
NSError *error;
[server listenToPort:8080 error:&error];
if (error) {
 NSLog(@"Couldn't start HTTP server: %@", error);
}

Usage

You might have noticed that Scarf doesn't have any Xcode project files. Instead, you're encouraged to use CocoaPods. Though you're free to copy the source files directly into your project (but keep in mind that you'll also need to add CocoaAsyncSocket yourself in this case). See the wiki for examples and documentation.

###With CocoaPods In this case, you'll just need a Podfile in your project (see the CocoaPods wiki for more information) with Scarf as a dependency:

pod 'Scarf', :git => 'https://github.com/dindresto/scarf.git'

###Without CocoaPods Just make sure you also get CocoaAsyncSocket.

Projects using Scarf

For now, this list is empty. Anyway, it would be nice of you to contact me if you use Scarf in one of your projects.

Other platforms

It may be possible to use Scarf on other platforms. Grand Central Dispatch is also available on FreeBSD and Linux (Debian, source), and you're free to port libdispatch to your favorite system, since it's open source. Aside of that, you'll also need a port of the Foundation Framework, like GNUStep, and a compiler with support for the new Objective-C literals (Clang 4.0 or newer).