Skip to content
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

Use RouteBuildItem instead of DefaultRouteBuildItem #12681

Merged
merged 1 commit into from
Oct 15, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;

import org.jboss.logging.Logger;

Expand All @@ -26,8 +25,10 @@
import io.quarkus.funqy.runtime.bindings.knative.events.KnativeEventsBindingRecorder;
import io.quarkus.jackson.ObjectMapperProducer;
import io.quarkus.vertx.core.deployment.CoreVertxBuildItem;
import io.quarkus.vertx.http.deployment.DefaultRouteBuildItem;
import io.vertx.ext.web.Route;
import io.quarkus.vertx.http.deployment.RouteBuildItem;
import io.quarkus.vertx.http.runtime.HttpBuildTimeConfig;
import io.vertx.core.Handler;
import io.vertx.ext.web.RoutingContext;

public class FunqyKnativeEventsBuildStep {
private static final Logger log = Logger.getLogger(FunqyKnativeEventsBuildStep.class);
Expand Down Expand Up @@ -60,20 +61,35 @@ public void boot(ShutdownContextBuildItem shutdown,
FunqyKnativeEventsConfig eventsConfig,
KnativeEventsBindingRecorder binding,
Optional<FunctionInitializedBuildItem> hasFunctions,
List<FunctionBuildItem> functions,
BuildProducer<FeatureBuildItem> feature,
BuildProducer<DefaultRouteBuildItem> defaultRoutes,
BuildProducer<RouteBuildItem> routes,
CoreVertxBuildItem vertx,
BeanContainerBuildItem beanContainer,
HttpBuildTimeConfig httpConfig,
ExecutorBuildItem executorBuildItem) throws Exception {
if (!hasFunctions.isPresent() || hasFunctions.get() == null)
return;

feature.produce(new FeatureBuildItem(FUNQY_KNATIVE_FEATURE));
Consumer<Route> ut = binding.start(funqyConfig, eventsConfig, vertx.getVertx(),
Handler<RoutingContext> handler = binding.start(funqyConfig, eventsConfig, vertx.getVertx(),
shutdown,
beanContainer.getValue(),
executorBuildItem.getExecutorProxy());

defaultRoutes.produce(new DefaultRouteBuildItem(ut));
String rootPath = httpConfig.rootPath;
if (rootPath == null) {
rootPath = "/";
} else if (!rootPath.endsWith("/")) {
rootPath += "/";
gastaldi marked this conversation as resolved.
Show resolved Hide resolved
}

routes.produce(new RouteBuildItem(rootPath, handler, false));

for (FunctionBuildItem function : functions) {
String name = function.getFunctionName() == null ? function.getMethodName() : function.getFunctionName();
String path = rootPath + name;
routes.produce(new RouteBuildItem(path, handler, false));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
import java.util.function.Supplier;

import org.jboss.logging.Logger;
Expand All @@ -29,7 +28,6 @@
import io.quarkus.runtime.annotations.Recorder;
import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.ext.web.Route;
import io.vertx.ext.web.RoutingContext;

/**
Expand Down Expand Up @@ -94,7 +92,7 @@ private ObjectMapper getObjectMapper() {
return new ObjectMapper();
}

public Consumer<Route> start(
public Handler<RoutingContext> start(
FunqyConfig funqyConfig,
FunqyKnativeEventsConfig eventsConfig,
Supplier<Vertx> vertx,
Expand Down Expand Up @@ -150,12 +148,6 @@ public void run() {
Handler<RoutingContext> handler = new VertxRequestHandler(vertx.get(), beanContainer, objectMapper, eventsConfig,
defaultInvoker, typeTriggers, executor);

return new Consumer<Route>() {

@Override
public void accept(Route route) {
route.handler(handler);
}
};
return handler;
}
}