Created
November 9, 2012 22:00
-
-
Save enigmaticape/4048566 to your computer and use it in GitHub Desktop.
Almost as small as the Python version,but not quite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import "HttpService.h" | |
@implementation WebService { | |
HttpService * _service; | |
} | |
- ( HTTPResponse * ) GET:( HTTPRequest * ) request { | |
HTTPResponse * response = [[HTTPResponse alloc]initWithResponseCode:200]; | |
[response setBodyText:[NSString stringWithFormat:@"GET %@",[request.url path]]]; | |
return [response autorelease]; | |
} | |
- ( HTTPResponse * ) POST:( HTTPRequest * ) request { | |
HTTPResponse * response = [[HTTPResponse alloc]initWithResponseCode:200]; | |
[response setBodyText:[NSString stringWithFormat:@"POST %@",[request.url path]]]; | |
return [response autorelease]; | |
} | |
- ( void ) startWebService | |
{ | |
_service = [[HttpService alloc] init]; | |
_service.responder = self; | |
[_service startServiceOnPort:4000]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Code that used the minimal(ish) web server framework in Gist https://gist.github.com/4024992. There is a discussion of it on my blog at http://www.enigmaticape.com/programming/a-minimalish-objective-c-http-server/