nitc: move up the default values of a project from the android platform
[nit.git] / examples / nitcorn / src / nitcorn_hello_world.nit
index 7eba06b..a9e8f55 100644 (file)
@@ -50,10 +50,29 @@ class StaticAction
        end
 end
 
+# An action that uses parameterized uris to customize the output.
+class ParamAction
+       super Action
+
+       redef fun answer(http_request, turi)
+       do
+               var response = new HttpResponse(200)
+               var name = http_request.param("name")
+               if name == null then
+                       response.body = "No name..."
+               else
+                       response.body = "Hello {name}"
+               end
+               return response
+       end
+end
+
+
 var vh = new VirtualHost("localhost:8080")
 
 # Serve index.html with our custom handler
 vh.routes.add new Route("/index.html", new StaticAction)
+vh.routes.add new Route("/hello/:name", new ParamAction)
 
 # Serve everything else with a standard `FileServer` with a root at "www/hello_world/"
 vh.routes.add new Route(null, new FileServer("www/hello_world/"))