-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppRoutes.java
More file actions
63 lines (58 loc) · 1.65 KB
/
Copy pathAppRoutes.java
File metadata and controls
63 lines (58 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.example.servlet;
import com.example.Html;
import io.github.ghosthack.turismo.action.Action;
import io.github.ghosthack.turismo.routes.RoutesList;
/**
* Routes for servlet deployment. {@link RoutesList} supports wildcards and
* named parameters; use {@code RoutesMap} instead for exact-match paths only.
*/
public class AppRoutes extends RoutesList {
@Override
protected void map() {
get("/", new Action() {
@Override
public void run() {
print("Hello World!");
}
});
get("/wild/*/card/:id", new Action() {
@Override
public void run() {
print("id " + Html.htmlEscape(params("id")));
}
});
get("/redir1", new Action() {
@Override
public void run() {
// 301 Moved Permanently
movedPermanently("/dest");
}
});
get("/redir2", new Action() {
@Override
public void run() {
// 302 Found
redirect("/dest");
}
});
get("/dest", new Action() {
@Override
public void run() {
print("Hello Redirect");
}
});
post("/search", new Action() {
@Override
public void run() {
String query = req().getParameter("q");
print("Your search query was: " + Html.htmlEscape(query));
}
});
route(new Action() {
@Override
public void run() {
notFound();
}
});
}
}