private CiEyeResponder route(Address target) {
final String[] path = target.getPath().getSegments();
if (path.length == 0) {
return new FileResponder("/resources/welcome.html");
}
if (path.length == 1) {
if ("mugshotconfig.html".equals(path[0])) {
return new FileResponder("/resources/mugshotconfig.html");
}
if ("landscapelist.json".equals(path[0])) {
return new LandscapeListResponder(landscapeFetcher);
}
if ("settingslocation.json".equals(path[0])) {
return new SettingsLocationResponder(configurationFetcher);
}
if ("version.json".equals(path[0])) {
return new CiEyeVersionResponder(configurationFetcher, updateChecker);
}
if ("sponsor.json".equals(path[0])) {
return new SponsorResponder(tracker);
}
final String name = "/resources/" + path[0];
if (null != getClass().getResource(name)) {
return new FileResponder(name);
}
}
if (path.length == 2) {
if ("pictures".equals(path[0])) {
return new PictureResponder(pictureFetcher, path[1]);
}
if ("landscapes".equals(path[0])) {
if (!target.getPath().getPath().endsWith("/")) {
return new RedirectResponder(target.getPath().getPath() + "/");
}
return new FileResponder("/resources/cieye.html");
}
}
if (path.length == 3) {
if ("landscapes".equals(path[0]) && "landscapeobservation.json".equals(path[2])) {