Skip to content

Commit

Permalink
fix service collision
Browse files Browse the repository at this point in the history
  • Loading branch information
SentryMan committed Nov 23, 2024
1 parent ad4ad3e commit 8bfc7ec
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ class FreeMarkerRenderTest {
static TestPair pair = init();

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

static class NoModel implements Routing.Service {
static class NoModel implements Routing.HttpService {
@Override
public void add(Routing routing) {
routing.get("/noModel", ctx -> ctx.render("one.ftl"));
}
}

static class WithModel implements Routing.Service {
static class WithModel implements Routing.HttpService {
@Override
public void add(Routing routing) {
routing.get("/withModel", ctx -> ctx.render("two.ftl", Map.of("message", "hello")));
Expand Down
6 changes: 3 additions & 3 deletions avaje-jex/src/main/java/io/avaje/jex/DJex.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ public <T> T attribute(Class<T> cls) {
}

@Override
public Jex routing(Routing.Service routes) {
public Jex routing(Routing.HttpService routes) {
routing.add(routes);
return this;
}

@Override
public Jex routing(Collection<Routing.Service> routes) {
public Jex routing(Collection<Routing.HttpService> routes) {
routing.addAll(routes);
return this;
}
Expand Down Expand Up @@ -70,7 +70,7 @@ public Jex configureWith(BeanScope beanScope) {
for (JexPlugin plugin : beanScope.list(JexPlugin.class)) {
plugin.apply(this);
}
routing.addAll(beanScope.list(Routing.Service.class));
routing.addAll(beanScope.list(Routing.HttpService.class));
beanScope.getOptional(JsonService.class).ifPresent(this::jsonService);
return this;
}
Expand Down
8 changes: 4 additions & 4 deletions avaje-jex/src/main/java/io/avaje/jex/DefaultRouting.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import io.avaje.jex.Routing.Entry;
import io.avaje.jex.Routing.Group;
import io.avaje.jex.Routing.Service;
import io.avaje.jex.Routing.HttpService;
import io.avaje.jex.Routing.Type;
import io.avaje.jex.security.Role;

Expand Down Expand Up @@ -55,14 +55,14 @@ private void addEndpoints(String path, Group group) {
}

@Override
public Routing add(Routing.Service routes) {
public Routing add(Routing.HttpService routes) {
routes.add(this);
return this;
}

@Override
public Routing addAll(Collection<Routing.Service> routes) {
for (Service route : routes) {
public Routing addAll(Collection<Routing.HttpService> routes) {
for (HttpService route : routes) {
route.add(this);
}
return this;
Expand Down
4 changes: 2 additions & 2 deletions avaje-jex/src/main/java/io/avaje/jex/Jex.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ static Jex create() {
/**
* Add routes and handlers to the routing.
*/
Jex routing(Routing.Service routes);
Jex routing(Routing.HttpService routes);

/**
* Add many routes and handlers to the routing.
*/
Jex routing(Collection<Routing.Service> routes);
Jex routing(Collection<Routing.HttpService> routes);

/**
* Return the Routing to configure.
Expand Down
8 changes: 4 additions & 4 deletions avaje-jex/src/main/java/io/avaje/jex/Routing.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
public sealed interface Routing permits DefaultRouting {

/**
* Add the routes provided by the Routing Service.
* Add the routes provided by the Routing HttpService.
*/
Routing add(Routing.Service routes);
Routing add(Routing.HttpService routes);

/**
* Add all the routes provided by the Routing Services.
*/
Routing addAll(Collection<Routing.Service> routes);
Routing addAll(Collection<Routing.HttpService> routes);

/**
* Specify permittedRoles for the last added handler.
Expand Down Expand Up @@ -186,7 +186,7 @@ interface Group {
* Adds to the Routing.
*/
@FunctionalInterface
interface Service {
interface HttpService {

/**
* Add to the routing.
Expand Down
2 changes: 1 addition & 1 deletion avaje-jex/src/main/java/io/avaje/jex/http/ErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public enum ErrorCode {
// 5xx Server Error
INTERNAL_SERVER_ERROR(500, "Internal Server Error"),
BAD_GATEWAY(502, "Bad Gateway"),
SERVICE_UNAVAILABLE(503, "Service Unavailable"),
SERVICE_UNAVAILABLE(503, "HttpService Unavailable"),
GATEWAY_TIMEOUT(504, "Gateway Timeout"),
HTTP_VERSION_NOT_SUPPORTED(505, "HTTP Version Not Supported"),
VARIANT_ALSO_NEGOTIATES(506, "Variant Also Negotiates"),
Expand Down
2 changes: 1 addition & 1 deletion avaje-jex/src/main/java/io/avaje/jex/spi/JsonService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.Iterator;

/**
* Service used to convert request/response bodies to beans.
* HttpService used to convert request/response bodies to beans.
*/
public non-sealed interface JsonService extends JexExtension {

Expand Down

0 comments on commit 8bfc7ec

Please sign in to comment.