Compare commits
No commits in common. "ddab72b438b347069ba588f952bf487da8e8861b" and "3971b249d9706000e658478945a415dc39ab4386" have entirely different histories.
ddab72b438
...
3971b249d9
2 changed files with 0 additions and 54 deletions
|
@ -1,5 +0,0 @@
|
|||
package com.spookyinternet.cobweb;
|
||||
|
||||
public interface HttpInspectFunction {
|
||||
void process(HttpRequest req);
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
package com.spookyinternet.cobweb;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class HttpRoute {
|
||||
private List<String> pieces;
|
||||
|
||||
public HttpRoute(String path, HttpInspectFunction fn) throws Exception {
|
||||
}
|
||||
|
||||
public HttpRoute(String path, HttpRequestFunction fn) throws Exception {
|
||||
this.pieces = new ArrayList<String>();
|
||||
|
||||
if(path.charAt(0) != '/') {
|
||||
throw new Exception("Invalid HTTP route: " + path);
|
||||
}
|
||||
|
||||
int idx = 0;
|
||||
int marker = 0;
|
||||
|
||||
while(idx < path.length()) {
|
||||
char rune = path.charAt(idx);
|
||||
|
||||
if(rune == '/' || rune == '*') {
|
||||
if(idx > marker) {
|
||||
pieces.add(path.substring(marker, idx));
|
||||
}
|
||||
|
||||
pieces.add(String.valueOf(rune));
|
||||
marker = idx + 1;
|
||||
} else if(rune == '{') {
|
||||
if(idx > marker) {
|
||||
pieces.add(path.substring(marker, idx));
|
||||
}
|
||||
|
||||
marker = idx;
|
||||
} else if(rune == '}') {
|
||||
pieces.add(path.substring(marker, idx + 1));
|
||||
marker = idx + 1;
|
||||
}
|
||||
|
||||
idx += 1;
|
||||
}
|
||||
|
||||
if(idx > marker) {
|
||||
pieces.add(path.substring(marker, idx + 1));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue