Permalink
Browse files

update readme

  • Loading branch information...
1 parent fbbd12a commit a93e441fde82cbcedeba48c2a76077f415b23733 Brian Guarraci committed Apr 12, 2012
Showing with 26 additions and 27 deletions.
  1. +26 −27 README.md
View
@@ -15,44 +15,43 @@ The following shows how two domains can be hosted on port 80.
The first, static.com, is a static content site that is hosted from embedded jar resources.
The second, rest.com, is a service with REST handlers. This service can easily be expanded to support both static and REST by extending StaticFileServer and adding the REST resources.
+ package nest.router
-package nest.router
+ import _root_.io.viper.core.server.router._
+ import io.viper.common.{NestServer, RestServer, StaticFileServer}
+ import java.util.Map
+ import org.json.JSONObject
-import _root_.io.viper.core.server.router._
-import io.viper.common.{NestServer, RestServer, StaticFileServer}
-import java.util.Map
-import org.json.JSONObject
+ object Main {
+ def main(args: Array[String]) {
+ val handler = new HostRouterHandler
-object Main {
- def main(args: Array[String]) {
- val handler = new HostRouterHandler
+ // Serve static.com from cached jar resources in the static.com directory
+ handler.putRoute("static.com", new StaticFileServer("res:///static.com/"))
- // Serve static.com from cached jar resources in the static.com directory
- handler.putRoute("static.com", new StaticFileServer("res:///static.com/"))
+ // Serve REST handlers
+ handler.putRoute("rest.com", new RestServer {
+ def addRoutes {
- // Serve REST handlers
- handler.putRoute("rest.com", new RestServer {
- def addRoutes {
+ get("/hello", new RouteHandler {
+ def exec(args: Map[String, String]): RouteResponse = new Utf8Response("world")
+ })
- get("/hello", new RouteHandler {
- def exec(args: Map[String, String]): RouteResponse = new Utf8Response("world")
- })
-
- get("/world", new RouteHandler {
- def exec(args: Map[String, String]): RouteResponse = {
- val json = new JSONObject()
- json.put("hello", "world")
- new JsonResponse(json)
+ get("/world", new RouteHandler {
+ def exec(args: Map[String, String]): RouteResponse = {
+ val json = new JSONObject()
+ json.put("hello", "world")
+ new JsonResponse(json)
+ }
+ })
}
})
- }
- })
- NestServer.run(handler)
- }
-}
+ NestServer.run(handler)
+ }
+ }
### Maven

0 comments on commit a93e441

Please sign in to comment.