Created
May 28, 2012 11:23
-
-
Save sheki/2818639 to your computer and use it in GitHub Desktop.
Finagle HTTP Server
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
| class ShowService extends Service[Request, Response] { | |
| def apply(request: Request) = { | |
| val response = new DefaultHttpResponse(HTTP_1_1, OK) | |
| response.setContent(copiedBuffer("show service world", UTF_8)) | |
| Future.value(Response(response)) | |
| } | |
| } | |
| class SearchService(val i : Int) extends Service[Request, Response] { | |
| def apply(request: Request) = { | |
| val response = new DefaultHttpResponse(HTTP_1_1, OK) | |
| response.setContent(copiedBuffer("search service world", UTF_8)) | |
| Future.value(Response(response)) | |
| } | |
| } | |
| val myShowService = new ShowService | |
| def main(args: Array[String]) { | |
| val handleExceptions = new HandleExceptions | |
| val authorize = new Authorize | |
| val respond = new Respond | |
| val routingService = | |
| RoutingService.byPathObject { | |
| case Root / "api1" / Integer(userId) => myShowService | |
| case Root / "api2" / Integer(userId) => new SearchService(userId) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment