Skip to content

Format Only Changes #197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
22 changes: 22 additions & 0 deletions .github/workflows/spotless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Spotless Check
on: [push, workflow_dispatch]

concurrency:
group: "${{ github.workflow }}-${{ github.event.number || github.ref }}"
cancel-in-progress: true
jobs:
check:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'zulu'
- name: Run Spotless Check
run: mvn --batch-mode --no-transfer-progress spotless:check
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package io.avaje.jex.render.freemarker;

import java.io.IOException;
import java.io.StringWriter;
import java.io.UncheckedIOException;
import java.util.Map;

import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import freemarker.template.Version;
import io.avaje.jex.http.Context;
import io.avaje.jex.spi.TemplateRender;
import io.avaje.spi.ServiceProvider;
import java.io.IOException;
import java.io.StringWriter;
import java.io.UncheckedIOException;
import java.util.Map;

@ServiceProvider
public class FreeMarkerRender implements TemplateRender {
Expand All @@ -34,7 +33,7 @@ private Configuration defaultConfiguration() {

@Override
public String[] defaultExtensions() {
return new String[]{"ftl"};
return new String[] {"ftl"};
}

@Override
Expand Down
5 changes: 2 additions & 3 deletions avaje-jex-freemarker/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
import io.avaje.jex.spi.JexExtension;

module io.avaje.jex.freemarker {

requires transitive io.avaje.jex;
requires transitive freemarker;
requires java.net.http;

requires static io.avaje.spi;

provides JexExtension with FreeMarkerRender;
provides JexExtension with
FreeMarkerRender;
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
package io.avaje.jex.render.freemarker;

import static org.assertj.core.api.Assertions.assertThat;

import io.avaje.jex.Jex;
import io.avaje.jex.Routing;
import io.avaje.jex.test.TestPair;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;

import java.net.http.HttpResponse;
import java.util.List;
import java.util.Map;

import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;

class FreeMarkerRenderTest {

static TestPair pair = init();

static TestPair init() {
final List<Routing.HttpService> services = List.of(new NoModel(), new WithModel());
var app = Jex.create()
.routing(services)
.register(new FreeMarkerRender(), "ftl");
var app = Jex.create().routing(services).register(new FreeMarkerRender(), "ftl");
return TestPair.create(app);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
package io.avaje.jex.render.freemarker;

import static org.assertj.core.api.Assertions.assertThat;

import io.avaje.jex.Jex;
import io.avaje.jex.test.TestPair;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;

import java.net.http.HttpResponse;
import java.util.Map;

import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;

class FreeMarkerServiceLoaderTest {

static TestPair pair = init();

static TestPair init() {
var app = Jex.create()
.routing(routing -> routing
.get("/noModel", ctx -> ctx.render("one.ftl"))
.get("/withModel", ctx -> ctx.render("two.ftl", Map.of("message", "hello")))
);
// not explicitly registered so auto registered via service loader
var app =
Jex.create()
.routing(
routing ->
routing
.get("/noModel", ctx -> ctx.render("one.ftl"))
.get(
"/withModel",
ctx -> ctx.render("two.ftl", Map.of("message", "hello"))));
// not explicitly registered so auto registered via service loader
return TestPair.create(app);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package io.avaje.jex.grizzly.spi;

import java.io.IOException;
import java.io.UncheckedIOException;

import org.glassfish.grizzly.http.server.Request;
import org.glassfish.grizzly.http.server.Response;

import com.sun.net.httpserver.Filter.Chain;
import com.sun.net.httpserver.HttpContext;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import java.io.IOException;
import java.io.UncheckedIOException;
import org.glassfish.grizzly.http.server.Request;
import org.glassfish.grizzly.http.server.Response;

final class GrizzlyHandler extends org.glassfish.grizzly.http.server.HttpHandler {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package io.avaje.jex.grizzly.spi;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.sun.net.httpserver.Authenticator;
import com.sun.net.httpserver.Filter;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

final class GrizzlyHttpContext extends com.sun.net.httpserver.HttpContext {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
package io.avaje.jex.grizzly.spi;

import com.sun.net.httpserver.Headers;
import com.sun.net.httpserver.HttpContext;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpPrincipal;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.URI;

import org.glassfish.grizzly.http.server.Request;
import org.glassfish.grizzly.http.server.Response;

import com.sun.net.httpserver.Headers;
import com.sun.net.httpserver.HttpContext;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpPrincipal;

final class GrizzlyHttpExchange extends HttpExchange implements GrizzlyExchange {
private final GrizzlyHttpExchangeDelegate delegate;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package io.avaje.jex.grizzly.spi;

import com.sun.net.httpserver.Headers;
import com.sun.net.httpserver.HttpContext;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpPrincipal;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand All @@ -9,15 +13,9 @@
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.glassfish.grizzly.http.server.Request;
import org.glassfish.grizzly.http.server.Response;

import com.sun.net.httpserver.Headers;
import com.sun.net.httpserver.HttpContext;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpPrincipal;

final class GrizzlyHttpExchangeDelegate extends HttpExchange {

/** Set of headers that RFC9110 says will not have a value list */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
package io.avaje.jex.grizzly.spi;

import com.sun.net.httpserver.HttpContext;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpsConfigurator;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.lang.System.Logger.Level;
import java.net.InetSocketAddress;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.grizzly.http.server.NetworkListener;
import org.glassfish.grizzly.http.server.ServerConfiguration;
import org.glassfish.grizzly.ssl.SSLEngineConfigurator;

import com.sun.net.httpserver.HttpContext;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpsConfigurator;

final class GrizzlyHttpServer extends com.sun.net.httpserver.HttpsServer {
private static final System.Logger LOG =
System.getLogger(GrizzlyHttpServer.class.getCanonicalName());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package io.avaje.jex.grizzly.spi;

import java.io.IOException;
import java.net.InetSocketAddress;

import org.glassfish.grizzly.http.server.HttpServer;

import com.sun.net.httpserver.HttpsServer;
import com.sun.net.httpserver.spi.HttpServerProvider;

import io.avaje.spi.ServiceProvider;
import java.io.IOException;
import java.net.InetSocketAddress;
import org.glassfish.grizzly.http.server.HttpServer;

@ServiceProvider
public class GrizzlyHttpServerProvider extends HttpServerProvider {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
package io.avaje.jex.grizzly.spi;

import com.sun.net.httpserver.Headers;
import com.sun.net.httpserver.HttpContext;
import com.sun.net.httpserver.HttpPrincipal;
import com.sun.net.httpserver.HttpsExchange;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.URI;

import javax.net.ssl.SSLSession;

import org.glassfish.grizzly.http.server.Request;
import org.glassfish.grizzly.http.server.Response;

import com.sun.net.httpserver.Headers;
import com.sun.net.httpserver.HttpContext;
import com.sun.net.httpserver.HttpPrincipal;
import com.sun.net.httpserver.HttpsExchange;

final class GrizzlyHttpsExchange extends HttpsExchange implements GrizzlyExchange {
private final GrizzlyHttpExchangeDelegate delegate;

Expand Down
5 changes: 2 additions & 3 deletions avaje-jex-grizzly-spi/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import com.sun.net.httpserver.spi.HttpServerProvider;

module io.avaje.jex.grizzly {

exports io.avaje.jex.grizzly.spi;

requires transitive io.avaje.jex;
requires transitive jdk.httpserver;
requires transitive org.glassfish.grizzly.http.server;
requires transitive org.glassfish.grizzly.http;
requires transitive org.glassfish.grizzly;

requires static io.avaje.spi;
requires static java.net.http;

provides HttpServerProvider with io.avaje.jex.grizzly.spi.GrizzlyHttpServerProvider;
provides HttpServerProvider with
io.avaje.jex.grizzly.spi.GrizzlyHttpServerProvider;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@

import static org.assertj.core.api.Assertions.assertThat;

import io.avaje.jex.Jex;
import io.avaje.jex.test.TestPair;
import java.net.http.HttpHeaders;
import java.net.http.HttpResponse;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.LockSupport;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;

import io.avaje.jex.Jex;
import io.avaje.jex.test.TestPair;

class FilterTest {

static final TestPair pair = init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public void handle(Context ctx) throws Exception {
}

private boolean matched(Context ctx) {
if ((target != null && notMatched(ctx.header(HX_TARGET), target)) || (trigger != null && notMatched(ctx.header(HX_TRIGGER), trigger))) {
if ((target != null && notMatched(ctx.header(HX_TARGET), target))
|| (trigger != null && notMatched(ctx.header(HX_TRIGGER), trigger))) {
return false;
}
return triggerName == null || !notMatched(ctx.header(HX_TRIGGER_NAME), triggerName);
Expand All @@ -39,5 +40,4 @@ private boolean matched(Context ctx) {
private boolean notMatched(String header, String matchValue) {
return header == null || !matchValue.equals(header);
}

}
Loading