Skip to content

Instantly share code, notes, and snippets.

@enigmaticape
Created November 9, 2012 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enigmaticape/4048566 to your computer and use it in GitHub Desktop.
Save enigmaticape/4048566 to your computer and use it in GitHub Desktop.
Almost as small as the Python version,but not quite
#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
@enigmaticape
Copy link
Author

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment