Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

README.md

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).

About

Non-blocking web server for Objective-C (OS X and iOS)

Resources

License

Releases

No releases published

Packages

No packages published