Created
November 28, 2009 06:54
-
-
Save beatty/244417 to your computer and use it in GitHub Desktop.
This file contains 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
object Example { | |
def main(args: Array[String]) { | |
val helloFunc = (request: Request) => new TextResponse("hello, " + request.routeParam("username") + "; extra message: " + request.queryParameter("extra").getOrElse("[unspecified]")) | |
val homeFunc = (request: Request) => new HtmlResponse("<html><body>homepage</body></html>") | |
val fileFunc = | |
val router = new Router(List( | |
(new RegexRoute("GET", "/person/([A-Za-z0-9]+)/profile", List("username")), helloFunc), | |
(new RegexRoute("GET", "/"), homeFunc), | |
(new RegexRoute("GET", "/README"), (request: Request) => new FileResponse(new File("tronada/README"))) | |
)) | |
val jettyServer = new JettyServer(router); | |
val server = jettyServer.create(); | |
server.start(); | |
server.join(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment