Dolda2000 GitWeb
/
jsvc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of git.dolda2000.com:/srv/git/r/jsvc
[jsvc.git]
/
src
/
dolda
/
jsvc
/
util
/
Multiplexer.java
diff --git
a/src/dolda/jsvc/util/Multiplexer.java
b/src/dolda/jsvc/util/Multiplexer.java
index
df9e4c2
..
8b003b7
100644
(file)
--- a/
src/dolda/jsvc/util/Multiplexer.java
+++ b/
src/dolda/jsvc/util/Multiplexer.java
@@
-5,10
+5,10
@@
import java.util.*;
public class Multiplexer implements Responder {
private Responder def;
public class Multiplexer implements Responder {
private Responder def;
- private Collection<
Sub> subs = new LinkedList<Sub
>();
+ private Collection<
Matcher> matchers = new LinkedList<Matcher
>();
- p
rivate static interface Sub
{
- boolean match(Request req);
+ p
ublic static interface Matcher
{
+
public
boolean match(Request req);
}
public Multiplexer(Responder def) {
}
public Multiplexer(Responder def) {
@@
-24,7
+24,7
@@
public class Multiplexer implements Responder {
}
public void file(final String path, final Responder responder) {
}
public void file(final String path, final Responder responder) {
-
subs.add(new Sub
() {
+
add(new Matcher
() {
public boolean match(Request req) {
if(req.path().equals(path)) {
responder.respond(req);
public boolean match(Request req) {
if(req.path().equals(path)) {
responder.respond(req);
@@
-37,7
+37,7
@@
public class Multiplexer implements Responder {
public void dir(String path, final Responder responder) {
final String fp = Misc.stripslashes(path, true, true);
public void dir(String path, final Responder responder) {
final String fp = Misc.stripslashes(path, true, true);
-
subs.add(new Sub
() {
+
add(new Matcher
() {
public boolean match(Request req) {
if(req.path().equals(fp)) {
throw(Restarts.redirect(fp + "/"));
public boolean match(Request req) {
if(req.path().equals(fp)) {
throw(Restarts.redirect(fp + "/"));
@@
-50,9
+50,13
@@
public class Multiplexer implements Responder {
});
}
});
}
+ public void add(Matcher m) {
+ matchers.add(m);
+ }
+
public void respond(Request req) {
public void respond(Request req) {
- for(
Sub s : sub
s) {
- if(
s
.match(req))
+ for(
Matcher m : matcher
s) {
+ if(
m
.match(req))
return;
}
def.respond(req);
return;
}
def.respond(req);