Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions avaje-jex/src/main/java/io/avaje/jex/FilterChain.java

This file was deleted.

24 changes: 22 additions & 2 deletions avaje-jex/src/main/java/io/avaje/jex/HttpFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

import java.io.IOException;

import com.sun.net.httpserver.HttpExchange;

/**
* A filter used to pre- and post-process incoming requests. Pre-processing occurs before the
* application's exchange handler is invoked, and post-processing occurs after the exchange handler
* returns. Filters are organized in chains, and are associated with {@link Context} instances.
*
* <p>Each {@code HttpFilter} in the chain, invokes the next filter within its own {@link
* #filter(Context, FilterChain)} implementation. The final {@code HttpFilter} in the chain invokes the
* applications exchange handler.
* #filter(Context, FilterChain)} implementation. The final {@code HttpFilter} in the chain invokes
* the applications exchange handler.
*/
@FunctionalInterface
public interface HttpFilter {
Expand All @@ -36,4 +38,22 @@ public interface HttpFilter {
* @param chain the {@code FilterChain} which allows the next filter to be invoked
*/
void filter(Context ctx, FilterChain chain) throws IOException;

/**
* Filter chain that contains all subsequent filters that are configured, as well as the final
* route.
*/
@FunctionalInterface
public interface FilterChain {

/**
* Calls the next filter in the chain, or else the user's exchange handler, if this is the final
* filter in the chain. The {@link HttpFilter} may decide to terminate the chain, by not calling
* this method. In this case, the filter <b>must</b> send the response to the request, because
* the application's {@linkplain HttpExchange exchange} handler will not be invoked.
*
* @throws IOException if an I/O error occurs
*/
void proceed() throws IOException;
}
}
6 changes: 0 additions & 6 deletions avaje-jex/src/main/java/io/avaje/jex/ResourceLocation.java

This file was deleted.

5 changes: 5 additions & 0 deletions avaje-jex/src/main/java/io/avaje/jex/StaticContentConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,9 @@ static StaticContentConfig create() {
* @return the updated configuration
*/
StaticContentConfig location(ResourceLocation location);

public enum ResourceLocation {
CLASS_PATH,
FILE
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.avaje.jex;

import static io.avaje.jex.ResourceLocation.CLASS_PATH;
import static io.avaje.jex.StaticContentConfig.ResourceLocation.CLASS_PATH;

import java.io.File;
import java.net.URL;
Expand Down
1 change: 1 addition & 0 deletions avaje-jex/src/test/java/io/avaje/jex/StaticFileTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;

import io.avaje.jex.StaticContentConfig.ResourceLocation;
import io.avaje.jex.jdk.TestPair;

class StaticFileTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.junit.jupiter.api.Test;

import io.avaje.jex.Jex;
import io.avaje.jex.ResourceLocation;
import io.avaje.jex.StaticContentConfig.ResourceLocation;
import io.avaje.jex.core.Constants;
import io.avaje.jex.jdk.TestPair;

Expand Down