Skip to content

Commit a583d29

Browse files
committed
Some clean-ups
1 parent 1a8f666 commit a583d29

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

src/express/Express.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,16 @@ private void addMiddleware(@NotNull String requestMethod, @NotNull String contex
185185
}
186186

187187
/**
188-
* Add an listener for all request methods.
188+
* Add an listener for all request methods and contexts.
189+
*
190+
* @param request Will be fired on all requests.
191+
*/
192+
public void all(@NotNull HttpRequest request) {
193+
HANDLER.add(1, new ExpressFilterImpl(this, "*", "*", request));
194+
}
195+
196+
/**
197+
* Adds an handler for a specific context.
189198
*
190199
* @param context The context.
191200
* @param request An listener which will be fired if the context matches the requestpath.
@@ -195,12 +204,15 @@ public void all(@NotNull String context, @NotNull HttpRequest request) {
195204
}
196205

197206
/**
198-
* Add an listener for all request methods and contexts.
207+
* Adds an handler for a specific context and method.
208+
* You can use a star '*' to match every context / request-method.
199209
*
200-
* @param request Will be fired on all requests.
210+
* @param context The context.
211+
* @param requestMethod The request method.
212+
* @param request An listener which will be fired if the context matches the requestpath.
201213
*/
202-
public void all(@NotNull HttpRequest request) {
203-
HANDLER.add(1, new ExpressFilterImpl(this, "*", "*", request));
214+
public void all(@NotNull String context, @NotNull String requestMethod, @NotNull HttpRequest request) {
215+
HANDLER.add(1, new ExpressFilterImpl(this, requestMethod, context, request));
204216
}
205217

206218
/**
@@ -254,29 +266,17 @@ public void patch(@NotNull String context, @NotNull HttpRequest request) {
254266
}
255267

256268
/**
257-
* Add an listener for an specific request method.
269+
* Adds an handler for a specific context and method.
270+
* You can use a star '*' to match every context / request-method.
258271
*
259-
* @param requestMethod The request method
260-
* @param context The context for the request handler.
272+
* @param context The context.
273+
* @param requestMethod The request method.
261274
* @param request An listener which will be fired if the context matches the requestpath.
262275
*/
263-
public void on(@NotNull String requestMethod, @NotNull String context, @NotNull HttpRequest request) {
276+
public void on(@NotNull String context, @NotNull String requestMethod, @NotNull HttpRequest request) {
264277
HANDLER.add(1, new ExpressFilterImpl(this, requestMethod, context, request));
265278
}
266279

267-
/**
268-
* Add an listener for an specific request method.
269-
* You cann add multiple contexts.
270-
*
271-
* @param requestMethod The request method
272-
* @param contexts The contexts for the request handler..
273-
* @param request An listener which will be fired if the context matches the requestpath.
274-
*/
275-
public void on(@NotNull String requestMethod, @NotNull HttpRequest request, String... contexts) {
276-
for (String c : contexts)
277-
HANDLER.add(1, new ExpressFilterImpl(this, requestMethod, c, request));
278-
}
279-
280280
/**
281281
* Start the HTTP-Server on port 80.
282282
* This method is asyncronous so be sure to add an listener or keep it in mind!

src/express/expressfilter/ExpressFilterImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
*/
1616
public class ExpressFilterImpl implements HttpRequest {
1717

18-
private final Express APP;
18+
private final Express EXPRESS;
1919

2020
private final HttpRequest REQUEST;
2121
private final String REQ;
2222
private final String CONTEXT;
2323
private final boolean REQ_ALL;
2424
private final boolean CONTEXT_ALL;
2525

26-
public ExpressFilterImpl(Express app, String requestMethod, String context, HttpRequest httpRequest) {
27-
this.APP = app;
26+
public ExpressFilterImpl(Express express, String requestMethod, String context, HttpRequest httpRequest) {
27+
this.EXPRESS = express;
2828
this.REQ = requestMethod;
2929
this.REQUEST = httpRequest;
3030
this.CONTEXT = context;
@@ -57,7 +57,7 @@ public void handle(Request req, Response res) {
5757

5858
// Check parameter lsitener
5959
params.forEach((s, s2) -> {
60-
HttpRequest hreq = APP.getParameterListener().get(s);
60+
HttpRequest hreq = EXPRESS.getParameterListener().get(s);
6161
if (hreq != null)
6262
hreq.handle(req, res);
6363
});

0 commit comments

Comments
 (0)