use of spark.template.velocity.VelocityRoute in project newts by OpenNMS.
the class Web method main.
public static void main(String... args) {
staticFileLocation("/static");
get(new VelocityRoute("/stations") {
@Override
public Object handle(Request request, Response response) {
Map<String, Object> model = Maps.newHashMap();
model.put("stationsMap", STATION_NAMES);
return modelAndView(model, "index.wm");
}
});
get(new VelocityRoute("/summer88") {
@Override
public Object handle(Request arg0, Response arg1) {
Map<String, Object> model = Maps.newHashMap();
model.put("stationIds", STATION_IDS);
return modelAndView(model, "summer.wm");
}
});
get(new VelocityRoute("/stations/:stationName") {
@Override
public Object handle(Request request, Response response) {
String stationName = request.params(":stationName");
String id = STATION_IDS.get(stationName);
if (id == null) {
halt(404, "No such station");
}
Map<String, String> model = Maps.newHashMap();
model.put("location", STATION_NAMES.get(stationName));
model.put("id", id);
model.put("start", request.queryParams("start"));
model.put("end", request.queryParams("end"));
model.put("resolution", request.queryParams("resolution"));
return modelAndView(model, "station.wm");
}
});
}
Aggregations