Skip to content

Instantly share code, notes, and snippets.

@stevenhuey stevenhuey/config.m
Created Sep 9, 2013

Embed
What would you like to do?
Barista Server Config.
- (void)runWithURL:(NSURL*)serverRoot onPort:(NSUInteger)port
{
_server = [BARServer serverWithPort:port];
[_server addGlobalMiddleware:[MarkdownTemplateRenderer rendererWithViewsDirectoryURL:serverRoot]];
BARRouter *router = [[BARRouter alloc] init];
[_server addGlobalMiddleware:router];
[router addRoute:@"/:view" forHTTPMethod:@"GET" handler:^BOOL(BARConnection *connection, BARRequest *request, NSDictionary *parameters)
{
BARResponse* response = [[BARResponse alloc] init];
response.statusCode = 200;
[response setViewToRender:parameters[@"view"]
withObject:@{}];
[connection sendResponse:response];
return YES;
}];
[_server startListening];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.