Skip to content

Commit

Permalink
made script name lowercase in compiled class map lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
puddingspudding committed Feb 26, 2017
1 parent 3172f89 commit e6f9ddf
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 54,31 @@ port=9500
threads=10
```

## Example
```java
// /var/www/Example.java => http://localhost/exmpale.java
import io.github.puddingspudding.nginj.HttpResponse;
import io.github.puddingspudding.nginj.Request;
import io.github.puddingspudding.nginj.Response;
import io.github.puddingspudding.nginj.http.GET;

import java.nio.ByteBuffer;
import java.util.HashMap;

public class Example {

@GET
public static Response get(final Request req) {
Response res = new HttpResponse();
res.setBody(ByteBuffer.wrap("GET Hello World".getBytes()));
res.setHeader(new HashMap<>());
res.setStatus(200);
return res;
}

}
```

## Build .deb
```
mvn clean package \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 134,12 @@ public void watch(Map<String, Class> compiledClasses) throws Exception {
watchKey.pollEvents().forEach(watchEvent -> {
Path path = ((Path) watchKey.watchable()).resolve((Path) watchEvent.context());
if (path.toFile().isFile()) {
String filePath = path.toString().toLowerCase();
WatchEvent.Kind kind = watchEvent.kind();
if (kind == StandardWatchEventKinds.ENTRY_DELETE) {
compiledClasses.remove(path.toString());
compiledClasses.remove(filePath);
} else {
compiledClasses.put(path.toString(), compile(path));
compiledClasses.put(filePath, compile(path));
}
} else {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 126,7 @@ public void accept(SocketChannel socketChannel) {
.setHeader(httpHeaders)
.setBody(ByteBuffer.wrap(data.toByteArray()));

String fileName = this.rootDir cgiHeaders.get("SCRIPT_NAME");
String fileName = (this.rootDir cgiHeaders.get("SCRIPT_NAME")).toLowerCase();

Path file = Paths.get(fileName);

Expand Down

0 comments on commit e6f9ddf

Please sign in to comment.