-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathRouter.java
More file actions
111 lines (97 loc) · 4.05 KB
/
Router.java
File metadata and controls
111 lines (97 loc) · 4.05 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package express;
import express.http.HttpRequestHandler;
/**
* @author Simon Reinisch
* Router interface for express
*/
public interface Router {
/**
* Add an middleware which will be called before each request-type listener will be fired.
*
* @param middleware An middleware which will be fired on every request-method and path.
* @return The router itself to allow method call chaining.
*/
Router use(HttpRequestHandler middleware);
/**
* Add an middleware which will be called before each request-type listener will be fired.
*
* @param context The context where the middleware should listen.
* @param middleware An middleware which will be fired if the context matches the request-path.
* @return The router itself to allow method call chaining.
*/
Router use(String context, HttpRequestHandler middleware);
/**
* Add an middleware which will be called before each request-type listener will be fired.
*
* @param context The context where the middleware should listen for the request handler..
* @param requestMethod And type of request-method eg. GET, POST etc.
* @param middleware An middleware which will be fired if the context matches the request-method- and path.
* @return The router itself to allow method call chaining.
*/
Router use(String context, String requestMethod, HttpRequestHandler middleware);
/**
* Add an listener for all request methods and contexts.
*
* @param request Will be fired on all requests.
* @return The router itself to allow method call chaining.
*/
Router all(HttpRequestHandler request);
/**
* Adds an handler for a specific context.
*
* @param context The context.
* @param request An listener which will be fired if the context matches the request-path.
* @return The router itself to allow method call chaining.
*/
Router all(String context, HttpRequestHandler request);
/**
* Adds an handler for a specific context and method.
* You can use a star '*' to match every context / request-method.
*
* @param context The context.
* @param requestMethod The request method.
* @param request An listener which will be fired if the context matches the request-path.
* @return The router itself to allow method call chaining.
*/
Router all(String context, String requestMethod, HttpRequestHandler request);
/**
* Add an listener for GET request's.
*
* @param context The context.
* @param request An listener which will be fired if the context matches the request-path.
* @return The router itself to allow method call chaining.
*/
Router get(String context, HttpRequestHandler request);
/**
* Add an listener for POST request's.
*
* @param context The context.
* @param request An listener which will be fired if the context matches the request-path.
* @return The router itself to allow method call chaining.
*/
Router post(String context, HttpRequestHandler request);
/**
* Add an listener for PUT request's.
*
* @param context The context for the request handler..
* @param request An listener which will be fired if the context matches the request-path.
* @return The router itself to allow method call chaining.
*/
Router put(String context, HttpRequestHandler request);
/**
* Add an listener for DELETE request's.
*
* @param context The context.
* @param request An listener which will be fired if the context matches the request-path.
* @return The router itself to allow method call chaining.
*/
Router delete(String context, HttpRequestHandler request);
/**
* Add an listener for PATCH request's.
*
* @param context The context.
* @param request An listener which will be fired if the context matches the request-path.
* @return The router itself to allow method call chaining.
*/
Router patch(String context, HttpRequestHandler request);
}