Skip to content

Commit a6cc29a

Browse files
authored
move filterChain and ResourceLocation (#94)
1 parent f98b4e3 commit a6cc29a

File tree

7 files changed

+30
-30
lines changed

7 files changed

+30
-30
lines changed

avaje-jex/src/main/java/io/avaje/jex/FilterChain.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

avaje-jex/src/main/java/io/avaje/jex/HttpFilter.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
import java.io.IOException;
44

5+
import com.sun.net.httpserver.HttpExchange;
6+
57
/**
68
* A filter used to pre- and post-process incoming requests. Pre-processing occurs before the
79
* application's exchange handler is invoked, and post-processing occurs after the exchange handler
810
* returns. Filters are organized in chains, and are associated with {@link Context} instances.
911
*
1012
* <p>Each {@code HttpFilter} in the chain, invokes the next filter within its own {@link
11-
* #filter(Context, FilterChain)} implementation. The final {@code HttpFilter} in the chain invokes the
12-
* applications exchange handler.
13+
* #filter(Context, FilterChain)} implementation. The final {@code HttpFilter} in the chain invokes
14+
* the applications exchange handler.
1315
*/
1416
@FunctionalInterface
1517
public interface HttpFilter {
@@ -36,4 +38,22 @@ public interface HttpFilter {
3638
* @param chain the {@code FilterChain} which allows the next filter to be invoked
3739
*/
3840
void filter(Context ctx, FilterChain chain) throws IOException;
41+
42+
/**
43+
* Filter chain that contains all subsequent filters that are configured, as well as the final
44+
* route.
45+
*/
46+
@FunctionalInterface
47+
public interface FilterChain {
48+
49+
/**
50+
* Calls the next filter in the chain, or else the user's exchange handler, if this is the final
51+
* filter in the chain. The {@link HttpFilter} may decide to terminate the chain, by not calling
52+
* this method. In this case, the filter <b>must</b> send the response to the request, because
53+
* the application's {@linkplain HttpExchange exchange} handler will not be invoked.
54+
*
55+
* @throws IOException if an I/O error occurs
56+
*/
57+
void proceed() throws IOException;
58+
}
3959
}

avaje-jex/src/main/java/io/avaje/jex/ResourceLocation.java

Lines changed: 0 additions & 6 deletions
This file was deleted.

avaje-jex/src/main/java/io/avaje/jex/StaticContentConfig.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,9 @@ static StaticContentConfig create() {
9090
* @return the updated configuration
9191
*/
9292
StaticContentConfig location(ResourceLocation location);
93+
94+
public enum ResourceLocation {
95+
CLASS_PATH,
96+
FILE
97+
}
9398
}

avaje-jex/src/main/java/io/avaje/jex/StaticResourceHandlerBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.avaje.jex;
22

3-
import static io.avaje.jex.ResourceLocation.CLASS_PATH;
3+
import static io.avaje.jex.StaticContentConfig.ResourceLocation.CLASS_PATH;
44

55
import java.io.File;
66
import java.net.URL;

avaje-jex/src/test/java/io/avaje/jex/StaticFileTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.junit.jupiter.api.AfterAll;
99
import org.junit.jupiter.api.Test;
1010

11+
import io.avaje.jex.StaticContentConfig.ResourceLocation;
1112
import io.avaje.jex.jdk.TestPair;
1213

1314
class StaticFileTest {

avaje-jex/src/test/java/io/avaje/jex/compression/CompressionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import org.junit.jupiter.api.Test;
99

1010
import io.avaje.jex.Jex;
11-
import io.avaje.jex.ResourceLocation;
11+
import io.avaje.jex.StaticContentConfig.ResourceLocation;
1212
import io.avaje.jex.core.Constants;
1313
import io.avaje.jex.jdk.TestPair;
1414

0 commit comments

Comments
 (0)