[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r330489639 ## File path: extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java ## @@ -0,0 +1,376 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.platform.http.runtime; + +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import io.vertx.core.MultiMap; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.http.HttpServerResponse; +import io.vertx.ext.web.Route; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.RoutingContext; +import io.vertx.ext.web.handler.BodyHandler; + +import org.apache.camel.Consumer; +import org.apache.camel.Endpoint; +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.apache.camel.NoTypeConversionAvailableException; +import org.apache.camel.Processor; +import org.apache.camel.TypeConversionException; +import org.apache.camel.TypeConverter; +import org.apache.camel.component.platform.http.PlatformHttpComponent; +import org.apache.camel.component.platform.http.PlatformHttpEndpoint; +import org.apache.camel.component.platform.http.spi.Method; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.support.DefaultConsumer; +import org.apache.camel.support.DefaultMessage; +import org.apache.camel.support.ExchangeHelper; +import org.apache.camel.support.MessageHelper; +import org.apache.camel.support.ObjectHelper; +import org.eclipse.microprofile.config.Config; +import org.eclipse.microprofile.config.ConfigProvider; +import org.jboss.logging.Logger; + +/** + * A Quarkus specific {@link Consumer} for the {@link PlatformHttpComponent}. + */ +public class QuarkusPlatformHttpConsumer extends DefaultConsumer { +private static final Logger LOG = Logger.getLogger("org.apache.camel.quarkus.component.platform.http"); + +private final Router router; +private Route route; + +public QuarkusPlatformHttpConsumer(Endpoint endpoint, Processor processor, Router router) { +super(endpoint, processor); +this.router = router; +} + +@Override +public PlatformHttpEndpoint getEndpoint() { +return (PlatformHttpEndpoint) super.getEndpoint(); +} + +@Override +protected void doStart() throws Exception { +super.doStart(); + +final String path = getEndpoint().getPath(); +final Route r = router.route(path); +final Set methods = getEndpoint().getEffectiveMethods(); +if (!methods.equals(Method.getAll())) { +methods.stream().forEach(m -> r.method(HttpMethod.valueOf(m.name(; +} + +Config cfg = ConfigProvider.getConfig(); +final BodyHandler bodyHandler = BodyHandler.create(); +/* Keep in sync with how the BodyHandler is configured in io.quarkus.vertx.web.runtime.VertxWebRecorder + * Eventually, VertxWebRecorder should have a method to do this for us. */ +cfg.getOptionalValue("quarkus.http.body.handle-file-uploads", boolean.class).ifPresent(bodyHandler::setHandleFileUploads); +cfg.getOptionalValue("quarkus.http.body.uploads-directory", String.class).ifPresent(bodyHandler::setUploadsDirectory); +cfg.getOptionalValue("quarkus.http.body.delete-uploaded-files-on-end", boolean.class).ifPresent(bodyHandler::setDeleteUploadedFilesOnEnd); +cfg.getOptionalValue("quarkus.http.body.merge-form-attributes", boolean.class).ifPresent(bodyHandler::setMergeFormAttributes); +cfg.getOptionalValue("quarkus.http.body.preallocate-body-buffer", boolean.class).ifPresent(bodyHandler::setPreallocateBodyBuffer); + +r +.handler(b
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r33040 ## File path: extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java ## @@ -0,0 +1,380 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.platform.http.runtime; + +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import io.vertx.core.MultiMap; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.http.HttpServerResponse; +import io.vertx.ext.web.Route; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.RoutingContext; +import io.vertx.ext.web.handler.BodyHandler; + +import org.apache.camel.Consumer; +import org.apache.camel.Endpoint; +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.apache.camel.NoTypeConversionAvailableException; +import org.apache.camel.Processor; +import org.apache.camel.TypeConversionException; +import org.apache.camel.TypeConverter; +import org.apache.camel.component.platform.http.PlatformHttpComponent; +import org.apache.camel.component.platform.http.PlatformHttpEndpoint; +import org.apache.camel.component.platform.http.spi.Method; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.support.DefaultConsumer; +import org.apache.camel.support.DefaultMessage; +import org.apache.camel.support.ExchangeHelper; +import org.apache.camel.support.MessageHelper; +import org.apache.camel.support.ObjectHelper; +import org.eclipse.microprofile.config.Config; +import org.eclipse.microprofile.config.ConfigProvider; +import org.jboss.logging.Logger; + +/** + * A Quarkus specific {@link Consumer} for the {@link PlatformHttpComponent}. + */ +public class QuarkusPlatformHttpConsumer extends DefaultConsumer { +private static final Logger LOG = Logger.getLogger(QuarkusPlatformHttpConsumer.class); + +private final Router router; +private Route route; + +public QuarkusPlatformHttpConsumer(Endpoint endpoint, Processor processor, Router router) { +super(endpoint, processor); +this.router = router; +} + +@Override +public PlatformHttpEndpoint getEndpoint() { +return (PlatformHttpEndpoint) super.getEndpoint(); +} + +@Override +protected void doStart() throws Exception { +super.doStart(); + +final String path = getEndpoint().getPath(); +final Route newRoute = router.route(path); + +final Set methods = Method.parseList(getEndpoint().getHttpMethodRestrict()); +if (!methods.equals(Method.getAll())) { +methods.stream().forEach(m -> newRoute.method(HttpMethod.valueOf(m.name(; +} + +Config cfg = ConfigProvider.getConfig(); +final BodyHandler bodyHandler = BodyHandler.create(); +/* Keep in sync with how the BodyHandler is configured in io.quarkus.vertx.web.runtime.VertxWebRecorder + * Eventually, VertxWebRecorder should have a method to do this for us. */ +cfg.getOptionalValue("quarkus.http.body.handle-file-uploads", boolean.class).ifPresent(bodyHandler::setHandleFileUploads); +cfg.getOptionalValue("quarkus.http.body.uploads-directory", String.class).ifPresent(bodyHandler::setUploadsDirectory); +cfg.getOptionalValue("quarkus.http.body.delete-uploaded-files-on-end", boolean.class).ifPresent(bodyHandler::setDeleteUploadedFilesOnEnd); +cfg.getOptionalValue("quarkus.http.body.merge-form-attributes", boolean.class).ifPresent(bodyHandler::setMergeFormAttributes); +cfg.getOptionalValue("quarkus.http.body.preallocate-body-buffer", boolean.class).ifPresent(bodyHandler::setPreallocateBodyBuffer); + +newRo
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r330021351 ## File path: extensions/platform-http/deployment/src/main/java/org/apache/camel/quarkus/component/platform/http/deployment/PlatformHttpProcessor.java ## @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.platform.http.deployment; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.annotations.ExecutionTime; +import io.quarkus.deployment.annotations.Record; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.vertx.http.deployment.VertxWebRouterBuildItem; + +import org.apache.camel.quarkus.component.platform.http.runtime.PlatformHttpRecorder; +import org.apache.camel.quarkus.core.deployment.CamelRuntimeBuildItem; + +class PlatformHttpProcessor { + +private static final String FEATURE = "camel-platform-http"; + +@BuildStep +FeatureBuildItem feature() { +return new FeatureBuildItem(FEATURE); +} + +@Record(ExecutionTime.RUNTIME_INIT) +@BuildStep +void platformHttpComponent(PlatformHttpRecorder recorder, CamelRuntimeBuildItem runtime, VertxWebRouterBuildItem router) { +recorder.registerPlatformHttpComponent(runtime.getRuntime(), router.getRouter()); Review comment: Will do this in a followup https://github.com/apache/camel-quarkus/issues/218 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r330020160 ## File path: extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java ## @@ -0,0 +1,132 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.platform.http; + +import java.util.Collections; +import java.util.Set; +import java.util.TreeSet; + +import org.apache.camel.AsyncEndpoint; +import org.apache.camel.Component; +import org.apache.camel.Consumer; +import org.apache.camel.Processor; +import org.apache.camel.Producer; +import org.apache.camel.component.platform.http.spi.Method; +import org.apache.camel.component.platform.http.spi.PlatformHttpEngine; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.spi.HeaderFilterStrategyAware; +import org.apache.camel.spi.UriEndpoint; +import org.apache.camel.spi.UriParam; +import org.apache.camel.support.DefaultEndpoint; + +@UriEndpoint(/* firstVersion = "3.?.0", */ scheme = "platform-http", title = "Platform HTTP", syntax = "platform-http:[methods:]path", label = "http") +public class PlatformHttpEndpoint extends DefaultEndpoint implements AsyncEndpoint, HeaderFilterStrategyAware { + +private final String path; +private final Set methods; + +@UriParam(label = "consumer", description = "A comma separated list of HTTP methods to serve. This list will be merged with the methods specified in the URI path. E.g. platform-http:GET,POST:/path?httpMethodRestrict=PUT,DELETE will effectivelly result in GET,POST,PUT,DELETE. If no methods are specified, all methods will be served.") +private String httpMethodRestrict; Review comment: Resolved in e66f2326c7bd4662dff548e7ba6272e2f1cd3668 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r330018350 ## File path: extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java ## @@ -0,0 +1,376 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.platform.http.runtime; + +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import io.vertx.core.MultiMap; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.http.HttpServerResponse; +import io.vertx.ext.web.Route; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.RoutingContext; +import io.vertx.ext.web.handler.BodyHandler; + +import org.apache.camel.Consumer; +import org.apache.camel.Endpoint; +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.apache.camel.NoTypeConversionAvailableException; +import org.apache.camel.Processor; +import org.apache.camel.TypeConversionException; +import org.apache.camel.TypeConverter; +import org.apache.camel.component.platform.http.PlatformHttpComponent; +import org.apache.camel.component.platform.http.PlatformHttpEndpoint; +import org.apache.camel.component.platform.http.spi.Method; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.support.DefaultConsumer; +import org.apache.camel.support.DefaultMessage; +import org.apache.camel.support.ExchangeHelper; +import org.apache.camel.support.MessageHelper; +import org.apache.camel.support.ObjectHelper; +import org.eclipse.microprofile.config.Config; +import org.eclipse.microprofile.config.ConfigProvider; +import org.jboss.logging.Logger; + +/** + * A Quarkus specific {@link Consumer} for the {@link PlatformHttpComponent}. + */ +public class QuarkusPlatformHttpConsumer extends DefaultConsumer { +private static final Logger LOG = Logger.getLogger("org.apache.camel.quarkus.component.platform.http"); Review comment: Solved in e66f2326c7bd4662dff548e7ba6272e2f1cd3668 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r330017047 ## File path: extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java ## @@ -0,0 +1,376 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.platform.http.runtime; + +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import io.vertx.core.MultiMap; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.http.HttpServerResponse; +import io.vertx.ext.web.Route; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.RoutingContext; +import io.vertx.ext.web.handler.BodyHandler; + +import org.apache.camel.Consumer; +import org.apache.camel.Endpoint; +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.apache.camel.NoTypeConversionAvailableException; +import org.apache.camel.Processor; +import org.apache.camel.TypeConversionException; +import org.apache.camel.TypeConverter; +import org.apache.camel.component.platform.http.PlatformHttpComponent; +import org.apache.camel.component.platform.http.PlatformHttpEndpoint; +import org.apache.camel.component.platform.http.spi.Method; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.support.DefaultConsumer; +import org.apache.camel.support.DefaultMessage; +import org.apache.camel.support.ExchangeHelper; +import org.apache.camel.support.MessageHelper; +import org.apache.camel.support.ObjectHelper; +import org.eclipse.microprofile.config.Config; +import org.eclipse.microprofile.config.ConfigProvider; +import org.jboss.logging.Logger; + +/** + * A Quarkus specific {@link Consumer} for the {@link PlatformHttpComponent}. + */ +public class QuarkusPlatformHttpConsumer extends DefaultConsumer { +private static final Logger LOG = Logger.getLogger("org.apache.camel.quarkus.component.platform.http"); + +private final Router router; +private Route route; + +public QuarkusPlatformHttpConsumer(Endpoint endpoint, Processor processor, Router router) { +super(endpoint, processor); +this.router = router; +} + +@Override +public PlatformHttpEndpoint getEndpoint() { +return (PlatformHttpEndpoint) super.getEndpoint(); +} + +@Override +protected void doStart() throws Exception { +super.doStart(); + +final String path = getEndpoint().getPath(); +final Route r = router.route(path); +final Set methods = getEndpoint().getEffectiveMethods(); +if (!methods.equals(Method.getAll())) { +methods.stream().forEach(m -> r.method(HttpMethod.valueOf(m.name(; +} + +Config cfg = ConfigProvider.getConfig(); +final BodyHandler bodyHandler = BodyHandler.create(); +/* Keep in sync with how the BodyHandler is configured in io.quarkus.vertx.web.runtime.VertxWebRecorder + * Eventually, VertxWebRecorder should have a method to do this for us. */ +cfg.getOptionalValue("quarkus.http.body.handle-file-uploads", boolean.class).ifPresent(bodyHandler::setHandleFileUploads); +cfg.getOptionalValue("quarkus.http.body.uploads-directory", String.class).ifPresent(bodyHandler::setUploadsDirectory); +cfg.getOptionalValue("quarkus.http.body.delete-uploaded-files-on-end", boolean.class).ifPresent(bodyHandler::setDeleteUploadedFilesOnEnd); +cfg.getOptionalValue("quarkus.http.body.merge-form-attributes", boolean.class).ifPresent(bodyHandler::setMergeFormAttributes); +cfg.getOptionalValue("quarkus.http.body.preallocate-body-buffer", boolean.class).ifPresent(bodyHandler::setPreallocateBodyBuffer); + +r +.handler(b
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r330016874 ## File path: extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java ## @@ -0,0 +1,376 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.platform.http.runtime; + +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import io.vertx.core.MultiMap; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.http.HttpServerResponse; +import io.vertx.ext.web.Route; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.RoutingContext; +import io.vertx.ext.web.handler.BodyHandler; + +import org.apache.camel.Consumer; +import org.apache.camel.Endpoint; +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.apache.camel.NoTypeConversionAvailableException; +import org.apache.camel.Processor; +import org.apache.camel.TypeConversionException; +import org.apache.camel.TypeConverter; +import org.apache.camel.component.platform.http.PlatformHttpComponent; +import org.apache.camel.component.platform.http.PlatformHttpEndpoint; +import org.apache.camel.component.platform.http.spi.Method; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.support.DefaultConsumer; +import org.apache.camel.support.DefaultMessage; +import org.apache.camel.support.ExchangeHelper; +import org.apache.camel.support.MessageHelper; +import org.apache.camel.support.ObjectHelper; +import org.eclipse.microprofile.config.Config; +import org.eclipse.microprofile.config.ConfigProvider; +import org.jboss.logging.Logger; + +/** + * A Quarkus specific {@link Consumer} for the {@link PlatformHttpComponent}. + */ +public class QuarkusPlatformHttpConsumer extends DefaultConsumer { +private static final Logger LOG = Logger.getLogger("org.apache.camel.quarkus.component.platform.http"); + +private final Router router; +private Route route; + +public QuarkusPlatformHttpConsumer(Endpoint endpoint, Processor processor, Router router) { +super(endpoint, processor); +this.router = router; +} + +@Override +public PlatformHttpEndpoint getEndpoint() { +return (PlatformHttpEndpoint) super.getEndpoint(); +} + +@Override +protected void doStart() throws Exception { +super.doStart(); + +final String path = getEndpoint().getPath(); +final Route r = router.route(path); +final Set methods = getEndpoint().getEffectiveMethods(); +if (!methods.equals(Method.getAll())) { +methods.stream().forEach(m -> r.method(HttpMethod.valueOf(m.name(; +} + +Config cfg = ConfigProvider.getConfig(); +final BodyHandler bodyHandler = BodyHandler.create(); +/* Keep in sync with how the BodyHandler is configured in io.quarkus.vertx.web.runtime.VertxWebRecorder + * Eventually, VertxWebRecorder should have a method to do this for us. */ +cfg.getOptionalValue("quarkus.http.body.handle-file-uploads", boolean.class).ifPresent(bodyHandler::setHandleFileUploads); +cfg.getOptionalValue("quarkus.http.body.uploads-directory", String.class).ifPresent(bodyHandler::setUploadsDirectory); +cfg.getOptionalValue("quarkus.http.body.delete-uploaded-files-on-end", boolean.class).ifPresent(bodyHandler::setDeleteUploadedFilesOnEnd); +cfg.getOptionalValue("quarkus.http.body.merge-form-attributes", boolean.class).ifPresent(bodyHandler::setMergeFormAttributes); +cfg.getOptionalValue("quarkus.http.body.preallocate-body-buffer", boolean.class).ifPresent(bodyHandler::setPreallocateBodyBuffer); + +r +.handler(b
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r330015867 ## File path: extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java ## @@ -0,0 +1,376 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.platform.http.runtime; + +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import io.vertx.core.MultiMap; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.http.HttpServerResponse; +import io.vertx.ext.web.Route; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.RoutingContext; +import io.vertx.ext.web.handler.BodyHandler; + +import org.apache.camel.Consumer; +import org.apache.camel.Endpoint; +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.apache.camel.NoTypeConversionAvailableException; +import org.apache.camel.Processor; +import org.apache.camel.TypeConversionException; +import org.apache.camel.TypeConverter; +import org.apache.camel.component.platform.http.PlatformHttpComponent; +import org.apache.camel.component.platform.http.PlatformHttpEndpoint; +import org.apache.camel.component.platform.http.spi.Method; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.support.DefaultConsumer; +import org.apache.camel.support.DefaultMessage; +import org.apache.camel.support.ExchangeHelper; +import org.apache.camel.support.MessageHelper; +import org.apache.camel.support.ObjectHelper; +import org.eclipse.microprofile.config.Config; +import org.eclipse.microprofile.config.ConfigProvider; +import org.jboss.logging.Logger; + +/** + * A Quarkus specific {@link Consumer} for the {@link PlatformHttpComponent}. + */ +public class QuarkusPlatformHttpConsumer extends DefaultConsumer { +private static final Logger LOG = Logger.getLogger("org.apache.camel.quarkus.component.platform.http"); + +private final Router router; +private Route route; + +public QuarkusPlatformHttpConsumer(Endpoint endpoint, Processor processor, Router router) { +super(endpoint, processor); +this.router = router; +} + +@Override +public PlatformHttpEndpoint getEndpoint() { +return (PlatformHttpEndpoint) super.getEndpoint(); +} + +@Override +protected void doStart() throws Exception { +super.doStart(); + +final String path = getEndpoint().getPath(); +final Route r = router.route(path); +final Set methods = getEndpoint().getEffectiveMethods(); +if (!methods.equals(Method.getAll())) { +methods.stream().forEach(m -> r.method(HttpMethod.valueOf(m.name(; +} + +Config cfg = ConfigProvider.getConfig(); +final BodyHandler bodyHandler = BodyHandler.create(); +/* Keep in sync with how the BodyHandler is configured in io.quarkus.vertx.web.runtime.VertxWebRecorder + * Eventually, VertxWebRecorder should have a method to do this for us. */ +cfg.getOptionalValue("quarkus.http.body.handle-file-uploads", boolean.class).ifPresent(bodyHandler::setHandleFileUploads); +cfg.getOptionalValue("quarkus.http.body.uploads-directory", String.class).ifPresent(bodyHandler::setUploadsDirectory); +cfg.getOptionalValue("quarkus.http.body.delete-uploaded-files-on-end", boolean.class).ifPresent(bodyHandler::setDeleteUploadedFilesOnEnd); +cfg.getOptionalValue("quarkus.http.body.merge-form-attributes", boolean.class).ifPresent(bodyHandler::setMergeFormAttributes); +cfg.getOptionalValue("quarkus.http.body.preallocate-body-buffer", boolean.class).ifPresent(bodyHandler::setPreallocateBodyBuffer); + +r +.handler(b
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r330015181 ## File path: extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java ## @@ -0,0 +1,376 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.platform.http.runtime; + +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import io.vertx.core.MultiMap; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.http.HttpServerResponse; +import io.vertx.ext.web.Route; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.RoutingContext; +import io.vertx.ext.web.handler.BodyHandler; + +import org.apache.camel.Consumer; +import org.apache.camel.Endpoint; +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.apache.camel.NoTypeConversionAvailableException; +import org.apache.camel.Processor; +import org.apache.camel.TypeConversionException; +import org.apache.camel.TypeConverter; +import org.apache.camel.component.platform.http.PlatformHttpComponent; +import org.apache.camel.component.platform.http.PlatformHttpEndpoint; +import org.apache.camel.component.platform.http.spi.Method; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.support.DefaultConsumer; +import org.apache.camel.support.DefaultMessage; +import org.apache.camel.support.ExchangeHelper; +import org.apache.camel.support.MessageHelper; +import org.apache.camel.support.ObjectHelper; +import org.eclipse.microprofile.config.Config; +import org.eclipse.microprofile.config.ConfigProvider; +import org.jboss.logging.Logger; + +/** + * A Quarkus specific {@link Consumer} for the {@link PlatformHttpComponent}. + */ +public class QuarkusPlatformHttpConsumer extends DefaultConsumer { +private static final Logger LOG = Logger.getLogger("org.apache.camel.quarkus.component.platform.http"); + +private final Router router; +private Route route; + +public QuarkusPlatformHttpConsumer(Endpoint endpoint, Processor processor, Router router) { +super(endpoint, processor); +this.router = router; +} + +@Override +public PlatformHttpEndpoint getEndpoint() { +return (PlatformHttpEndpoint) super.getEndpoint(); +} + +@Override +protected void doStart() throws Exception { +super.doStart(); + +final String path = getEndpoint().getPath(); +final Route r = router.route(path); Review comment: `rte` would not look self explaining. Took `newRoute` FWIW. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r330013855 ## File path: extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java ## @@ -0,0 +1,376 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.platform.http.runtime; + +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import io.vertx.core.MultiMap; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.http.HttpServerResponse; +import io.vertx.ext.web.Route; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.RoutingContext; +import io.vertx.ext.web.handler.BodyHandler; + +import org.apache.camel.Consumer; +import org.apache.camel.Endpoint; +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.apache.camel.NoTypeConversionAvailableException; +import org.apache.camel.Processor; +import org.apache.camel.TypeConversionException; +import org.apache.camel.TypeConverter; +import org.apache.camel.component.platform.http.PlatformHttpComponent; +import org.apache.camel.component.platform.http.PlatformHttpEndpoint; +import org.apache.camel.component.platform.http.spi.Method; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.support.DefaultConsumer; +import org.apache.camel.support.DefaultMessage; +import org.apache.camel.support.ExchangeHelper; +import org.apache.camel.support.MessageHelper; +import org.apache.camel.support.ObjectHelper; +import org.eclipse.microprofile.config.Config; +import org.eclipse.microprofile.config.ConfigProvider; +import org.jboss.logging.Logger; + +/** + * A Quarkus specific {@link Consumer} for the {@link PlatformHttpComponent}. + */ +public class QuarkusPlatformHttpConsumer extends DefaultConsumer { +private static final Logger LOG = Logger.getLogger("org.apache.camel.quarkus.component.platform.http"); + +private final Router router; +private Route route; + +public QuarkusPlatformHttpConsumer(Endpoint endpoint, Processor processor, Router router) { +super(endpoint, processor); +this.router = router; +} + +@Override +public PlatformHttpEndpoint getEndpoint() { +return (PlatformHttpEndpoint) super.getEndpoint(); +} + +@Override +protected void doStart() throws Exception { +super.doStart(); + +final String path = getEndpoint().getPath(); +final Route r = router.route(path); Review comment: How many letters is enough, BTW? Going to use 3 and wonder whether 2 would pass your filter too? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r330013233 ## File path: extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java ## @@ -0,0 +1,376 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.platform.http.runtime; + +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import io.vertx.core.MultiMap; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.http.HttpServerResponse; +import io.vertx.ext.web.Route; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.RoutingContext; +import io.vertx.ext.web.handler.BodyHandler; + +import org.apache.camel.Consumer; +import org.apache.camel.Endpoint; +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.apache.camel.NoTypeConversionAvailableException; +import org.apache.camel.Processor; +import org.apache.camel.TypeConversionException; +import org.apache.camel.TypeConverter; +import org.apache.camel.component.platform.http.PlatformHttpComponent; +import org.apache.camel.component.platform.http.PlatformHttpEndpoint; +import org.apache.camel.component.platform.http.spi.Method; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.support.DefaultConsumer; +import org.apache.camel.support.DefaultMessage; +import org.apache.camel.support.ExchangeHelper; +import org.apache.camel.support.MessageHelper; +import org.apache.camel.support.ObjectHelper; +import org.eclipse.microprofile.config.Config; +import org.eclipse.microprofile.config.ConfigProvider; +import org.jboss.logging.Logger; + +/** + * A Quarkus specific {@link Consumer} for the {@link PlatformHttpComponent}. + */ +public class QuarkusPlatformHttpConsumer extends DefaultConsumer { +private static final Logger LOG = Logger.getLogger("org.apache.camel.quarkus.component.platform.http"); + +private final Router router; +private Route route; + +public QuarkusPlatformHttpConsumer(Endpoint endpoint, Processor processor, Router router) { +super(endpoint, processor); +this.router = router; +} + +@Override +public PlatformHttpEndpoint getEndpoint() { +return (PlatformHttpEndpoint) super.getEndpoint(); +} + +@Override +protected void doStart() throws Exception { +super.doStart(); + +final String path = getEndpoint().getPath(); +final Route r = router.route(path); Review comment: Frankly have not got that point, sorry :) And never saw that as an issue for a variable ranging over just a couple of lines. No problem with changing it though. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r330012304 ## File path: extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpHeaderFilterStrategy.java ## @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.platform.http; + +import org.apache.camel.support.DefaultHeaderFilterStrategy; + +public class PlatformHttpHeaderFilterStrategy extends DefaultHeaderFilterStrategy { Review comment: Done in 7c292ebc4ee38f0bda8ed182c29d3cdc3957a0dd This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r330011943 ## File path: extensions/platform-http/component/pom.xml ## @@ -0,0 +1,57 @@ + + +http://maven.apache.org/POM/4.0.0"; + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd";> +4.0.0 + +org.apache.camel.quarkus +camel-quarkus-platform-http-parent +0.1.1-SNAPSHOT +../pom.xml + + +camel-quarkus-platform-http-component +Camel Quarkus :: Platform HTTP :: Component + + + + +org.apache.camel.quarkus +camel-quarkus-bom +${project.version} +pom +import + + + + + + +org.apache.camel +camel-support + + +org.apache.camel +spi-annotations + + Review comment: Added apt in 7c292ebc4ee38f0bda8ed182c29d3cdc3957a0dd This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r330011459 ## File path: extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java ## @@ -0,0 +1,132 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.platform.http; + +import java.util.Collections; +import java.util.Set; +import java.util.TreeSet; + +import org.apache.camel.AsyncEndpoint; +import org.apache.camel.Component; +import org.apache.camel.Consumer; +import org.apache.camel.Processor; +import org.apache.camel.Producer; +import org.apache.camel.component.platform.http.spi.Method; +import org.apache.camel.component.platform.http.spi.PlatformHttpEngine; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.spi.HeaderFilterStrategyAware; +import org.apache.camel.spi.UriEndpoint; +import org.apache.camel.spi.UriParam; +import org.apache.camel.support.DefaultEndpoint; + +@UriEndpoint(/* firstVersion = "3.?.0", */ scheme = "platform-http", title = "Platform HTTP", syntax = "platform-http:[methods:]path", label = "http") +public class PlatformHttpEndpoint extends DefaultEndpoint implements AsyncEndpoint, HeaderFilterStrategyAware { + +private final String path; +private final Set methods; + +@UriParam(label = "consumer", description = "A comma separated list of HTTP methods to serve. This list will be merged with the methods specified in the URI path. E.g. platform-http:GET,POST:/path?httpMethodRestrict=PUT,DELETE will effectivelly result in GET,POST,PUT,DELETE. If no methods are specified, all methods will be served.") +private String httpMethodRestrict; + +@UriParam(label = "advanced") +private PlatformHttpEngine platformHttpEngine; + +@UriParam(label = "advanced") +private HeaderFilterStrategy headerFilterStrategy = new PlatformHttpHeaderFilterStrategy(); + +public PlatformHttpEndpoint(String uri, String remaining, Component component) { +super(uri, component); + +final String[] remainingParts = remaining.split(":"); +switch (remainingParts.length) { +case 1: +path = remaining; +methods = null; +break; +case 2: +methods = Method.parseList(remainingParts[0]); +path = remainingParts[1]; +break; +default: +throw new IllegalArgumentException("Expected a path or two segments delimited by ':'; found " + remaining); +} +} + +@Override +public Producer createProducer() throws Exception { +throw new UnsupportedOperationException("Producer is not supported"); +} + +@Override +public Consumer createConsumer(Processor processor) throws Exception { +if (platformHttpEngine == null) { +platformHttpEngine = getCamelContext().getRegistry() + .lookupByNameAndType(PlatformHttpConstants.PLATFORM_HTTP_ENGINE_NAME, PlatformHttpEngine.class); +} +return platformHttpEngine.createConsumer(this, processor); +} + +public Set getEffectiveMethods() { Review comment: Removed in 7c292ebc4ee38f0bda8ed182c29d3cdc3957a0dd This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r330011280 ## File path: extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java ## @@ -0,0 +1,132 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.platform.http; + +import java.util.Collections; +import java.util.Set; +import java.util.TreeSet; + +import org.apache.camel.AsyncEndpoint; +import org.apache.camel.Component; +import org.apache.camel.Consumer; +import org.apache.camel.Processor; +import org.apache.camel.Producer; +import org.apache.camel.component.platform.http.spi.Method; +import org.apache.camel.component.platform.http.spi.PlatformHttpEngine; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.spi.HeaderFilterStrategyAware; +import org.apache.camel.spi.UriEndpoint; +import org.apache.camel.spi.UriParam; +import org.apache.camel.support.DefaultEndpoint; + +@UriEndpoint(/* firstVersion = "3.?.0", */ scheme = "platform-http", title = "Platform HTTP", syntax = "platform-http:[methods:]path", label = "http") +public class PlatformHttpEndpoint extends DefaultEndpoint implements AsyncEndpoint, HeaderFilterStrategyAware { + +private final String path; +private final Set methods; + +@UriParam(label = "consumer", description = "A comma separated list of HTTP methods to serve. This list will be merged with the methods specified in the URI path. E.g. platform-http:GET,POST:/path?httpMethodRestrict=PUT,DELETE will effectivelly result in GET,POST,PUT,DELETE. If no methods are specified, all methods will be served.") +private String httpMethodRestrict; + +@UriParam(label = "advanced") +private PlatformHttpEngine platformHttpEngine; + +@UriParam(label = "advanced") +private HeaderFilterStrategy headerFilterStrategy = new PlatformHttpHeaderFilterStrategy(); + +public PlatformHttpEndpoint(String uri, String remaining, Component component) { +super(uri, component); + +final String[] remainingParts = remaining.split(":"); +switch (remainingParts.length) { +case 1: +path = remaining; +methods = null; +break; +case 2: +methods = Method.parseList(remainingParts[0]); +path = remainingParts[1]; +break; +default: +throw new IllegalArgumentException("Expected a path or two segments delimited by ':'; found " + remaining); +} +} + +@Override +public Producer createProducer() throws Exception { +throw new UnsupportedOperationException("Producer is not supported"); +} + +@Override +public Consumer createConsumer(Processor processor) throws Exception { +if (platformHttpEngine == null) { +platformHttpEngine = getCamelContext().getRegistry() Review comment: Done in 7c292ebc4ee38f0bda8ed182c29d3cdc3957a0dd The bottom line is that the omnipresent mutable state makes it very easy do something wrong. I wonder whether there ever was some discussion to aim at making Camel more functional. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r33330 ## File path: extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java ## @@ -0,0 +1,376 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.platform.http.runtime; + +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import io.vertx.core.MultiMap; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.http.HttpServerResponse; +import io.vertx.ext.web.Route; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.RoutingContext; +import io.vertx.ext.web.handler.BodyHandler; + +import org.apache.camel.Consumer; +import org.apache.camel.Endpoint; +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.apache.camel.NoTypeConversionAvailableException; +import org.apache.camel.Processor; +import org.apache.camel.TypeConversionException; +import org.apache.camel.TypeConverter; +import org.apache.camel.component.platform.http.PlatformHttpComponent; +import org.apache.camel.component.platform.http.PlatformHttpEndpoint; +import org.apache.camel.component.platform.http.spi.Method; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.support.DefaultConsumer; +import org.apache.camel.support.DefaultMessage; +import org.apache.camel.support.ExchangeHelper; +import org.apache.camel.support.MessageHelper; +import org.apache.camel.support.ObjectHelper; +import org.eclipse.microprofile.config.Config; +import org.eclipse.microprofile.config.ConfigProvider; +import org.jboss.logging.Logger; + +/** + * A Quarkus specific {@link Consumer} for the {@link PlatformHttpComponent}. + */ +public class QuarkusPlatformHttpConsumer extends DefaultConsumer { +private static final Logger LOG = Logger.getLogger("org.apache.camel.quarkus.component.platform.http"); + +private final Router router; +private Route route; + +public QuarkusPlatformHttpConsumer(Endpoint endpoint, Processor processor, Router router) { +super(endpoint, processor); +this.router = router; +} + +@Override +public PlatformHttpEndpoint getEndpoint() { +return (PlatformHttpEndpoint) super.getEndpoint(); +} + +@Override +protected void doStart() throws Exception { +super.doStart(); + +final String path = getEndpoint().getPath(); +final Route r = router.route(path); +final Set methods = getEndpoint().getEffectiveMethods(); +if (!methods.equals(Method.getAll())) { +methods.stream().forEach(m -> r.method(HttpMethod.valueOf(m.name(; +} + +Config cfg = ConfigProvider.getConfig(); +final BodyHandler bodyHandler = BodyHandler.create(); +/* Keep in sync with how the BodyHandler is configured in io.quarkus.vertx.web.runtime.VertxWebRecorder + * Eventually, VertxWebRecorder should have a method to do this for us. */ +cfg.getOptionalValue("quarkus.http.body.handle-file-uploads", boolean.class).ifPresent(bodyHandler::setHandleFileUploads); +cfg.getOptionalValue("quarkus.http.body.uploads-directory", String.class).ifPresent(bodyHandler::setUploadsDirectory); +cfg.getOptionalValue("quarkus.http.body.delete-uploaded-files-on-end", boolean.class).ifPresent(bodyHandler::setDeleteUploadedFilesOnEnd); +cfg.getOptionalValue("quarkus.http.body.merge-form-attributes", boolean.class).ifPresent(bodyHandler::setMergeFormAttributes); +cfg.getOptionalValue("quarkus.http.body.preallocate-body-buffer", boolean.class).ifPresent(bodyHandler::setPreallocateBodyBuffer); + +r +.handler(b
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r329995223 ## File path: extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java ## @@ -0,0 +1,376 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.platform.http.runtime; + +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import io.vertx.core.MultiMap; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.http.HttpServerResponse; +import io.vertx.ext.web.Route; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.RoutingContext; +import io.vertx.ext.web.handler.BodyHandler; + +import org.apache.camel.Consumer; +import org.apache.camel.Endpoint; +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.apache.camel.NoTypeConversionAvailableException; +import org.apache.camel.Processor; +import org.apache.camel.TypeConversionException; +import org.apache.camel.TypeConverter; +import org.apache.camel.component.platform.http.PlatformHttpComponent; +import org.apache.camel.component.platform.http.PlatformHttpEndpoint; +import org.apache.camel.component.platform.http.spi.Method; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.support.DefaultConsumer; +import org.apache.camel.support.DefaultMessage; +import org.apache.camel.support.ExchangeHelper; +import org.apache.camel.support.MessageHelper; +import org.apache.camel.support.ObjectHelper; +import org.eclipse.microprofile.config.Config; +import org.eclipse.microprofile.config.ConfigProvider; +import org.jboss.logging.Logger; + +/** + * A Quarkus specific {@link Consumer} for the {@link PlatformHttpComponent}. + */ +public class QuarkusPlatformHttpConsumer extends DefaultConsumer { +private static final Logger LOG = Logger.getLogger("org.apache.camel.quarkus.component.platform.http"); + +private final Router router; +private Route route; + +public QuarkusPlatformHttpConsumer(Endpoint endpoint, Processor processor, Router router) { +super(endpoint, processor); +this.router = router; +} + +@Override +public PlatformHttpEndpoint getEndpoint() { +return (PlatformHttpEndpoint) super.getEndpoint(); +} + +@Override +protected void doStart() throws Exception { +super.doStart(); + +final String path = getEndpoint().getPath(); +final Route r = router.route(path); +final Set methods = getEndpoint().getEffectiveMethods(); +if (!methods.equals(Method.getAll())) { +methods.stream().forEach(m -> r.method(HttpMethod.valueOf(m.name(; +} + +Config cfg = ConfigProvider.getConfig(); +final BodyHandler bodyHandler = BodyHandler.create(); +/* Keep in sync with how the BodyHandler is configured in io.quarkus.vertx.web.runtime.VertxWebRecorder + * Eventually, VertxWebRecorder should have a method to do this for us. */ +cfg.getOptionalValue("quarkus.http.body.handle-file-uploads", boolean.class).ifPresent(bodyHandler::setHandleFileUploads); +cfg.getOptionalValue("quarkus.http.body.uploads-directory", String.class).ifPresent(bodyHandler::setUploadsDirectory); +cfg.getOptionalValue("quarkus.http.body.delete-uploaded-files-on-end", boolean.class).ifPresent(bodyHandler::setDeleteUploadedFilesOnEnd); +cfg.getOptionalValue("quarkus.http.body.merge-form-attributes", boolean.class).ifPresent(bodyHandler::setMergeFormAttributes); +cfg.getOptionalValue("quarkus.http.body.preallocate-body-buffer", boolean.class).ifPresent(bodyHandler::setPreallocateBodyBuffer); + +r +.handler(b
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r329994613 ## File path: extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java ## @@ -0,0 +1,376 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.platform.http.runtime; + +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import io.vertx.core.MultiMap; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.http.HttpServerResponse; +import io.vertx.ext.web.Route; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.RoutingContext; +import io.vertx.ext.web.handler.BodyHandler; + +import org.apache.camel.Consumer; +import org.apache.camel.Endpoint; +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.apache.camel.NoTypeConversionAvailableException; +import org.apache.camel.Processor; +import org.apache.camel.TypeConversionException; +import org.apache.camel.TypeConverter; +import org.apache.camel.component.platform.http.PlatformHttpComponent; +import org.apache.camel.component.platform.http.PlatformHttpEndpoint; +import org.apache.camel.component.platform.http.spi.Method; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.support.DefaultConsumer; +import org.apache.camel.support.DefaultMessage; +import org.apache.camel.support.ExchangeHelper; +import org.apache.camel.support.MessageHelper; +import org.apache.camel.support.ObjectHelper; +import org.eclipse.microprofile.config.Config; +import org.eclipse.microprofile.config.ConfigProvider; +import org.jboss.logging.Logger; + +/** + * A Quarkus specific {@link Consumer} for the {@link PlatformHttpComponent}. + */ +public class QuarkusPlatformHttpConsumer extends DefaultConsumer { +private static final Logger LOG = Logger.getLogger("org.apache.camel.quarkus.component.platform.http"); + +private final Router router; +private Route route; + +public QuarkusPlatformHttpConsumer(Endpoint endpoint, Processor processor, Router router) { +super(endpoint, processor); +this.router = router; +} + +@Override +public PlatformHttpEndpoint getEndpoint() { +return (PlatformHttpEndpoint) super.getEndpoint(); +} + +@Override +protected void doStart() throws Exception { +super.doStart(); + +final String path = getEndpoint().getPath(); +final Route r = router.route(path); +final Set methods = getEndpoint().getEffectiveMethods(); +if (!methods.equals(Method.getAll())) { +methods.stream().forEach(m -> r.method(HttpMethod.valueOf(m.name(; +} + +Config cfg = ConfigProvider.getConfig(); +final BodyHandler bodyHandler = BodyHandler.create(); +/* Keep in sync with how the BodyHandler is configured in io.quarkus.vertx.web.runtime.VertxWebRecorder + * Eventually, VertxWebRecorder should have a method to do this for us. */ +cfg.getOptionalValue("quarkus.http.body.handle-file-uploads", boolean.class).ifPresent(bodyHandler::setHandleFileUploads); +cfg.getOptionalValue("quarkus.http.body.uploads-directory", String.class).ifPresent(bodyHandler::setUploadsDirectory); +cfg.getOptionalValue("quarkus.http.body.delete-uploaded-files-on-end", boolean.class).ifPresent(bodyHandler::setDeleteUploadedFilesOnEnd); +cfg.getOptionalValue("quarkus.http.body.merge-form-attributes", boolean.class).ifPresent(bodyHandler::setMergeFormAttributes); +cfg.getOptionalValue("quarkus.http.body.preallocate-body-buffer", boolean.class).ifPresent(bodyHandler::setPreallocateBodyBuffer); + +r +.handler(b
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r329994374 ## File path: extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java ## @@ -0,0 +1,376 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.platform.http.runtime; + +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import io.vertx.core.MultiMap; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.http.HttpServerResponse; +import io.vertx.ext.web.Route; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.RoutingContext; +import io.vertx.ext.web.handler.BodyHandler; + +import org.apache.camel.Consumer; +import org.apache.camel.Endpoint; +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.apache.camel.NoTypeConversionAvailableException; +import org.apache.camel.Processor; +import org.apache.camel.TypeConversionException; +import org.apache.camel.TypeConverter; +import org.apache.camel.component.platform.http.PlatformHttpComponent; +import org.apache.camel.component.platform.http.PlatformHttpEndpoint; +import org.apache.camel.component.platform.http.spi.Method; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.support.DefaultConsumer; +import org.apache.camel.support.DefaultMessage; +import org.apache.camel.support.ExchangeHelper; +import org.apache.camel.support.MessageHelper; +import org.apache.camel.support.ObjectHelper; +import org.eclipse.microprofile.config.Config; +import org.eclipse.microprofile.config.ConfigProvider; +import org.jboss.logging.Logger; + +/** + * A Quarkus specific {@link Consumer} for the {@link PlatformHttpComponent}. + */ +public class QuarkusPlatformHttpConsumer extends DefaultConsumer { +private static final Logger LOG = Logger.getLogger("org.apache.camel.quarkus.component.platform.http"); + +private final Router router; +private Route route; + +public QuarkusPlatformHttpConsumer(Endpoint endpoint, Processor processor, Router router) { +super(endpoint, processor); +this.router = router; +} + +@Override +public PlatformHttpEndpoint getEndpoint() { +return (PlatformHttpEndpoint) super.getEndpoint(); +} + +@Override +protected void doStart() throws Exception { +super.doStart(); + +final String path = getEndpoint().getPath(); +final Route r = router.route(path); Review comment: Are you sure? `router` would clash with the `router` field. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r329950820 ## File path: extensions/platform-http/deployment/src/main/java/org/apache/camel/quarkus/component/platform/http/deployment/PlatformHttpProcessor.java ## @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.platform.http.deployment; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.annotations.ExecutionTime; +import io.quarkus.deployment.annotations.Record; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.vertx.http.deployment.VertxWebRouterBuildItem; + +import org.apache.camel.quarkus.component.platform.http.runtime.PlatformHttpRecorder; +import org.apache.camel.quarkus.core.deployment.CamelRuntimeBuildItem; + +class PlatformHttpProcessor { + +private static final String FEATURE = "camel-platform-http"; + +@BuildStep +FeatureBuildItem feature() { +return new FeatureBuildItem(FEATURE); +} + +@Record(ExecutionTime.RUNTIME_INIT) +@BuildStep +void platformHttpComponent(PlatformHttpRecorder recorder, CamelRuntimeBuildItem runtime, VertxWebRouterBuildItem router) { +recorder.registerPlatformHttpComponent(runtime.getRuntime(), router.getRouter()); Review comment: Good point. Let me figure out how to ensure that. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r329950196 ## File path: extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/PlatformHttpRecorder.java ## @@ -0,0 +1,24 @@ +package org.apache.camel.quarkus.component.platform.http.runtime; + +import org.apache.camel.component.platform.http.PlatformHttpComponent; +import org.apache.camel.component.platform.http.PlatformHttpConstants; +import org.apache.camel.component.platform.http.spi.PlatformHttpEngine; +import org.apache.camel.quarkus.core.runtime.CamelRuntime; +import org.apache.camel.spi.Registry; + +import io.quarkus.arc.runtime.BeanContainer; +import io.quarkus.runtime.RuntimeValue; +import io.quarkus.runtime.annotations.Recorder; + +@Recorder +public class PlatformHttpRecorder { + +public void registerBeans(RuntimeValue runtime, BeanContainer beanContainer) { +final Registry registry = runtime.getValue().getRegistry(); +final QuarkusPlatformHttpEngine engine = beanContainer.instance(QuarkusPlatformHttpEngine.class); Review comment: In bb474bb, the bean container is not involved. The `QuarkusPlatformHttpEngine` is created in the recorder though, which is in line with the requirement of Quarkus that the runtime objects should not be created inside BuildSteps. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r329950422 ## File path: extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpEngine.java ## @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.platform.http.runtime; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.inject.Named; + +import org.apache.camel.Consumer; +import org.apache.camel.Processor; +import org.apache.camel.component.platform.http.PlatformHttpConstants; +import org.apache.camel.component.platform.http.PlatformHttpEndpoint; +import org.apache.camel.component.platform.http.spi.PlatformHttpEngine; +import org.jboss.logging.Logger; + +import io.vertx.ext.web.Router; + +@ApplicationScoped +@Named(PlatformHttpConstants.PLATFORM_HTTP_ENGINE_NAME) +public class QuarkusPlatformHttpEngine implements PlatformHttpEngine { Review comment: Improved in bb474bb as far as possible. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r329108060 ## File path: extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java ## @@ -0,0 +1,132 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.platform.http; + +import java.util.Collections; +import java.util.Set; +import java.util.TreeSet; + +import org.apache.camel.AsyncEndpoint; +import org.apache.camel.Component; +import org.apache.camel.Consumer; +import org.apache.camel.Processor; +import org.apache.camel.Producer; +import org.apache.camel.component.platform.http.spi.Method; +import org.apache.camel.component.platform.http.spi.PlatformHttpEngine; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.spi.HeaderFilterStrategyAware; +import org.apache.camel.spi.UriEndpoint; +import org.apache.camel.spi.UriParam; +import org.apache.camel.support.DefaultEndpoint; + +@UriEndpoint(/* firstVersion = "3.?.0", */ scheme = "platform-http", title = "Platform HTTP", syntax = "platform-http:[methods:]path", label = "http") +public class PlatformHttpEndpoint extends DefaultEndpoint implements AsyncEndpoint, HeaderFilterStrategyAware { + +private final String path; +private final Set methods; + +@UriParam(label = "consumer", description = "A comma separated list of HTTP methods to serve. This list will be merged with the methods specified in the URI path. E.g. platform-http:GET,POST:/path?httpMethodRestrict=PUT,DELETE will effectivelly result in GET,POST,PUT,DELETE. If no methods are specified, all methods will be served.") +private String httpMethodRestrict; Review comment: I am not sure I follow. Could you please explain it in more detail? We do change substantial parts of the URI (no protocol, no host, no port) so there apparently is something new and we are not going to be 100% compatible with the older generation of the HTTP components. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r329008926 ## File path: extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java ## @@ -0,0 +1,132 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.platform.http; + +import java.util.Collections; +import java.util.Set; +import java.util.TreeSet; + +import org.apache.camel.AsyncEndpoint; +import org.apache.camel.Component; +import org.apache.camel.Consumer; +import org.apache.camel.Processor; +import org.apache.camel.Producer; +import org.apache.camel.component.platform.http.spi.Method; +import org.apache.camel.component.platform.http.spi.PlatformHttpEngine; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.spi.HeaderFilterStrategyAware; +import org.apache.camel.spi.UriEndpoint; +import org.apache.camel.spi.UriParam; +import org.apache.camel.support.DefaultEndpoint; + +@UriEndpoint(/* firstVersion = "3.?.0", */ scheme = "platform-http", title = "Platform HTTP", syntax = "platform-http:[methods:]path", label = "http") +public class PlatformHttpEndpoint extends DefaultEndpoint implements AsyncEndpoint, HeaderFilterStrategyAware { + +private final String path; +private final Set methods; + +@UriParam(label = "consumer", description = "A comma separated list of HTTP methods to serve. This list will be merged with the methods specified in the URI path. E.g. platform-http:GET,POST:/path?httpMethodRestrict=PUT,DELETE will effectivelly result in GET,POST,PUT,DELETE. If no methods are specified, all methods will be served.") +private String httpMethodRestrict; Review comment: The component is incubating here and the API/SPI will eventually move to Camel when it is mature enough. So IMO this is a way how to address it in Camel. I agree that consistency with the old stuff is nice when migrating and to keep the old knowledge usable but the developer experience is the king for green field projects where the old stuff does not matter that much. It is amazing to see how excited people get when they see Panache. Applying your argument there, Panache should not be introduced because it is reaching the same goal as the well established Hibernate? I do not think that would be the right approach. I see `platform-http` as the new generation of the HTTP components where we SHOULD be compatible with the old generation as far as possible but at the same time it should not block us from improving things. Having to type 18 chars less to define a route is IMO an improvement that justifies having two ways of configuring the same thing. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r328998471 ## File path: extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpEngine.java ## @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.platform.http.runtime; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.inject.Named; + +import org.apache.camel.Consumer; +import org.apache.camel.Processor; +import org.apache.camel.component.platform.http.PlatformHttpConstants; +import org.apache.camel.component.platform.http.PlatformHttpEndpoint; +import org.apache.camel.component.platform.http.spi.PlatformHttpEngine; +import org.jboss.logging.Logger; + +import io.vertx.ext.web.Router; + +@ApplicationScoped +@Named(PlatformHttpConstants.PLATFORM_HTTP_ENGINE_NAME) +public class QuarkusPlatformHttpEngine implements PlatformHttpEngine { Review comment: Same as above - this is possible since Quarkus 0.23. I vote for improving this later. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r328998134 ## File path: extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/PlatformHttpRecorder.java ## @@ -0,0 +1,24 @@ +package org.apache.camel.quarkus.component.platform.http.runtime; + +import org.apache.camel.component.platform.http.PlatformHttpComponent; +import org.apache.camel.component.platform.http.PlatformHttpConstants; +import org.apache.camel.component.platform.http.spi.PlatformHttpEngine; +import org.apache.camel.quarkus.core.runtime.CamelRuntime; +import org.apache.camel.spi.Registry; + +import io.quarkus.arc.runtime.BeanContainer; +import io.quarkus.runtime.RuntimeValue; +import io.quarkus.runtime.annotations.Recorder; + +@Recorder +public class PlatformHttpRecorder { + +public void registerBeans(RuntimeValue runtime, BeanContainer beanContainer) { +final Registry registry = runtime.getValue().getRegistry(); +final QuarkusPlatformHttpEngine engine = beanContainer.instance(QuarkusPlatformHttpEngine.class); Review comment: Indeed, but only since Quarkus 0.23. I'd prefer improving this later when we are on 0.23 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r328992945 ## File path: extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java ## @@ -0,0 +1,359 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.platform.http.runtime; + +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import io.vertx.core.MultiMap; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.http.HttpServerResponse; +import io.vertx.ext.web.Route; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.RoutingContext; + +import org.apache.camel.Consumer; +import org.apache.camel.Endpoint; +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.apache.camel.NoTypeConversionAvailableException; +import org.apache.camel.Processor; +import org.apache.camel.TypeConversionException; +import org.apache.camel.TypeConverter; +import org.apache.camel.component.platform.http.PlatformHttpComponent; +import org.apache.camel.component.platform.http.PlatformHttpEndpoint; +import org.apache.camel.component.platform.http.spi.Method; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.support.DefaultConsumer; +import org.apache.camel.support.DefaultMessage; +import org.apache.camel.support.ExchangeHelper; +import org.apache.camel.support.MessageHelper; +import org.apache.camel.support.ObjectHelper; + +/** + * A Quarkus specific {@link Consumer} for the {@link PlatformHttpComponent}. + */ +public class QuarkusPlatformHttpConsumer extends DefaultConsumer { +private final Router router; +private final Object routeLock = new Object(); +private Route route; + +public QuarkusPlatformHttpConsumer(Endpoint endpoint, Processor processor, Router router) { +super(endpoint, processor); +this.router = router; +} + +@Override +public PlatformHttpEndpoint getEndpoint() { +return (PlatformHttpEndpoint) super.getEndpoint(); +} + +@Override +protected void doStart() throws Exception { +super.doStart(); + +synchronized (routeLock) { +route = router.route(getEndpoint().getPath()); +final Setmethods = getEndpoint().getEffectiveMethods(); +if (!methods.equals(Method.getAll())) { +methods.stream().forEach(m -> route.method(HttpMethod.valueOf(m.name(; +} + +route.handler(ctx -> { +try { +Exchange e = toExchange(ctx, getEndpoint().createExchange(), +getEndpoint().getHeaderFilterStrategy()); +getProcessor().process(e); +writeResponse(ctx, e, getEndpoint().getHeaderFilterStrategy()); +} catch (Exception e1) { +throw new RuntimeException(e1); +} +}); +} +} + +@Override +protected void doStop() throws Exception { +synchronized (routeLock) { Review comment: +1 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r328992879 ## File path: extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java ## @@ -0,0 +1,359 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.platform.http.runtime; + +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import io.vertx.core.MultiMap; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.http.HttpServerResponse; +import io.vertx.ext.web.Route; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.RoutingContext; + +import org.apache.camel.Consumer; +import org.apache.camel.Endpoint; +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.apache.camel.NoTypeConversionAvailableException; +import org.apache.camel.Processor; +import org.apache.camel.TypeConversionException; +import org.apache.camel.TypeConverter; +import org.apache.camel.component.platform.http.PlatformHttpComponent; +import org.apache.camel.component.platform.http.PlatformHttpEndpoint; +import org.apache.camel.component.platform.http.spi.Method; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.support.DefaultConsumer; +import org.apache.camel.support.DefaultMessage; +import org.apache.camel.support.ExchangeHelper; +import org.apache.camel.support.MessageHelper; +import org.apache.camel.support.ObjectHelper; + +/** + * A Quarkus specific {@link Consumer} for the {@link PlatformHttpComponent}. + */ +public class QuarkusPlatformHttpConsumer extends DefaultConsumer { +private final Router router; +private final Object routeLock = new Object(); +private Route route; + +public QuarkusPlatformHttpConsumer(Endpoint endpoint, Processor processor, Router router) { +super(endpoint, processor); +this.router = router; +} + +@Override +public PlatformHttpEndpoint getEndpoint() { +return (PlatformHttpEndpoint) super.getEndpoint(); +} + +@Override +protected void doStart() throws Exception { +super.doStart(); + +synchronized (routeLock) { Review comment: Thanks, now I see there is a similar lock in ServiceSupport. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r328989625 ## File path: extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/PlatformHttpRecorder.java ## @@ -0,0 +1,24 @@ +package org.apache.camel.quarkus.component.platform.http.runtime; + +import org.apache.camel.component.platform.http.PlatformHttpComponent; +import org.apache.camel.component.platform.http.PlatformHttpConstants; +import org.apache.camel.component.platform.http.spi.PlatformHttpEngine; +import org.apache.camel.quarkus.core.runtime.CamelRuntime; +import org.apache.camel.spi.Registry; + +import io.quarkus.arc.runtime.BeanContainer; +import io.quarkus.runtime.RuntimeValue; +import io.quarkus.runtime.annotations.Recorder; + +@Recorder +public class PlatformHttpRecorder { + +public void registerBeans(RuntimeValue runtime, BeanContainer beanContainer) { +final Registry registry = runtime.getValue().getRegistry(); +final QuarkusPlatformHttpEngine engine = beanContainer.instance(QuarkusPlatformHttpEngine.class); Review comment: `QuarkusPlatformHttpEngine` needs to `@Inject` the `Router`. How could that work without the bean container? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r328988066 ## File path: extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java ## @@ -0,0 +1,132 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.platform.http; + +import java.util.Collections; +import java.util.Set; +import java.util.TreeSet; + +import org.apache.camel.AsyncEndpoint; +import org.apache.camel.Component; +import org.apache.camel.Consumer; +import org.apache.camel.Processor; +import org.apache.camel.Producer; +import org.apache.camel.component.platform.http.spi.Method; +import org.apache.camel.component.platform.http.spi.PlatformHttpEngine; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.spi.HeaderFilterStrategyAware; +import org.apache.camel.spi.UriEndpoint; +import org.apache.camel.spi.UriParam; +import org.apache.camel.support.DefaultEndpoint; + +@UriEndpoint(/* firstVersion = "3.?.0", */ scheme = "platform-http", title = "Platform HTTP", syntax = "platform-http:[methods:]path", label = "http") +public class PlatformHttpEndpoint extends DefaultEndpoint implements AsyncEndpoint, HeaderFilterStrategyAware { + +private final String path; +private final Set methods; + +@UriParam(label = "consumer", description = "A comma separated list of HTTP methods to serve. This list will be merged with the methods specified in the URI path. E.g. platform-http:GET,POST:/path?httpMethodRestrict=PUT,DELETE will effectivelly result in GET,POST,PUT,DELETE. If no methods are specified, all methods will be served.") +private String httpMethodRestrict; Review comment: `platform-http:GET:/platform-http/hello` is shorter, faster to type and faster to read than `platform-http:/platform-http/hello?httpMethodRestrict=GET` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r324336543 ## File path: extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/http/server/QuarkusPlatformHttpEngine.java ## @@ -0,0 +1,317 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.http.server; + +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.inject.Named; + +import io.vertx.core.MultiMap; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.http.HttpServerResponse; +import io.vertx.ext.web.Route; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.RoutingContext; + +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.apache.camel.NoTypeConversionAvailableException; +import org.apache.camel.TypeConversionException; +import org.apache.camel.TypeConverter; +import org.apache.camel.component.http.server.PlatformHttpConstants; +import org.apache.camel.component.http.server.spi.HttpEndpointSpec; +import org.apache.camel.component.http.server.spi.Method; +import org.apache.camel.component.http.server.spi.PlatformHttpEngine; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.support.DefaultMessage; +import org.apache.camel.support.ExchangeHelper; +import org.apache.camel.support.MessageHelper; +import org.apache.camel.support.ObjectHelper; +import org.jboss.logging.Logger; + +@ApplicationScoped +@Named(PlatformHttpConstants.PLATFORM_HTTP_ENGINE_NAME) +public class QuarkusPlatformHttpEngine implements PlatformHttpEngine { Review comment: I did not think there is any difference, but after some testing, I now see there is one. Thanks for the hint! This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r324336074 ## File path: extensions/platform-http/component/pom.xml ## @@ -0,0 +1,57 @@ + + +http://maven.apache.org/POM/4.0.0"; + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd";> +4.0.0 + +org.apache.camel.quarkus +camel-quarkus-platform-http-parent +0.1.1-SNAPSHOT +../pom.xml + + +camel-quarkus-platform-http-component +Camel Quarkus :: Platform HTTP :: Component + + + + +org.apache.camel.quarkus +camel-quarkus-bom +${project.version} +pom +import + + + + + + +org.apache.camel +camel-support + + +org.apache.camel +spi-annotations + + Review comment: I looked into Camel main repo and I cannot say I understand which mojos are necessary. I vote to follow up on this later. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r324335692 ## File path: extensions/platform-http/component/src/main/java/org/apache/camel/component/http/server/PlatformHttpConsumer.java ## @@ -0,0 +1,81 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.http.server; + +import java.util.Set; + +import org.apache.camel.Endpoint; +import org.apache.camel.Exchange; +import org.apache.camel.ExchangePattern; +import org.apache.camel.Processor; +import org.apache.camel.component.http.server.spi.HttpEndpointSpec; +import org.apache.camel.component.http.server.spi.Method; +import org.apache.camel.component.http.server.spi.PlatformHttpEngine; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.support.DefaultConsumer; + +public class PlatformHttpConsumer extends DefaultConsumer implements HttpEndpointSpec { + +public PlatformHttpConsumer(Endpoint endpoint, Processor processor) { +super(endpoint, processor); +} + +@Override +protected void doStart() throws Exception { +super.doStart(); +final PlatformHttpEngine platformHttpEngine = getEndpoint().getCamelContext().getRegistry() + .lookupByNameAndType(PlatformHttpConstants.PLATFORM_HTTP_ENGINE_NAME, PlatformHttpEngine.class); +platformHttpEngine.deploy(this); Review comment: Done in QuarkusPlatformHttpConsumer This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r324335567 ## File path: extensions/platform-http/component/src/main/java/org/apache/camel/component/http/server/PlatformHttpConsumer.java ## @@ -0,0 +1,81 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.http.server; + +import java.util.Set; + +import org.apache.camel.Endpoint; +import org.apache.camel.Exchange; +import org.apache.camel.ExchangePattern; +import org.apache.camel.Processor; +import org.apache.camel.component.http.server.spi.HttpEndpointSpec; +import org.apache.camel.component.http.server.spi.Method; +import org.apache.camel.component.http.server.spi.PlatformHttpEngine; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.support.DefaultConsumer; + +public class PlatformHttpConsumer extends DefaultConsumer implements HttpEndpointSpec { Review comment: `HttpEndpointSpec` is gone, but `QuarkusPlatformHttpConsumer` is still needed IMO. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r324335301 ## File path: extensions/platform-http/component/src/main/java/org/apache/camel/component/http/server/PlatformHttpComponent.java ## @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.http.server; + +import java.util.Map; +import java.util.Set; + +import org.apache.camel.CamelContext; +import org.apache.camel.Endpoint; +import org.apache.camel.component.http.server.spi.Method; +import org.apache.camel.support.DefaultComponent; + +public class PlatformHttpComponent extends DefaultComponent { + +public PlatformHttpComponent() { +super(); +} + +public PlatformHttpComponent(CamelContext context) { +super(context); +} + +@Override +protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception { +final String[] remainingParts = remaining.split(":"); +if (remainingParts.length != 2) { +throw new IllegalArgumentException("Expected two segments delimited by ':'; found " + remaining); +} +final Set methods = Method.parseList(remainingParts[0]); +final String path = remainingParts[1]; +return new PlatformHttpEndpoint(uri, this, methods, path); +} + Review comment: Done, thanks. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r324335090 ## File path: extensions/platform-http/component/src/main/java/org/apache/camel/component/http/server/PlatformHttpEndpoint.java ## @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.http.server; + +import java.util.Set; + +import org.apache.camel.AsyncEndpoint; +import org.apache.camel.Component; +import org.apache.camel.Consumer; +import org.apache.camel.Processor; +import org.apache.camel.Producer; +import org.apache.camel.component.http.server.spi.Method; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.spi.HeaderFilterStrategyAware; +import org.apache.camel.spi.UriParam; +import org.apache.camel.support.DefaultEndpoint; + +public class PlatformHttpEndpoint extends DefaultEndpoint implements AsyncEndpoint, HeaderFilterStrategyAware { Review comment: Thanks, I added some, plz re-check. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r324335215 ## File path: extensions/platform-http/component/src/main/java/org/apache/camel/component/http/server/PlatformHttpComponent.java ## @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.http.server; + +import java.util.Map; +import java.util.Set; + +import org.apache.camel.CamelContext; +import org.apache.camel.Endpoint; +import org.apache.camel.component.http.server.spi.Method; +import org.apache.camel.support.DefaultComponent; + +public class PlatformHttpComponent extends DefaultComponent { Review comment: Done, thanks. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r324334899 ## File path: extensions/platform-http/component/src/main/java/org/apache/camel/component/http/server/spi/PlatformHttpEngine.java ## @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.http.server.spi; + +/** + * An abstraction of an HTTP Server engine on which HTTP endpoints can be deployed. + */ +public interface PlatformHttpEngine { + +/** + * Deploys the given {@link HttpEndpointSpec} on this {@link PlatformHttpEngine} + * + * @param spec the {@link HttpEndpointSpec} to deploy + */ +void deploy(HttpEndpointSpec spec); Review comment: I tried to provide a simple and hard to break interface for the implementors because I tend to mistrust camel model as fragile due to its mutability and overused inheritance. You are right it can be done like you say and it might feel more natural to camelists so I followed your wish. `QuarkusPlatformHttpConsumer` now also takes care for the stop, suspend and resume. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r324263195 ## File path: extensions/platform-http/component/src/main/java/org/apache/camel/component/http/server/spi/Method.java ## @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.http.server.spi; + +import java.util.Arrays; +import java.util.Collections; +import java.util.Locale; +import java.util.Set; +import java.util.TreeSet; + +/** + * An HTTP method. + */ +public enum Method { Review comment: > depending on `camel-http-common` and excluding the servlet ... does not work ootb, because some converters auto-loaded by http-common depend on servlet ``` org.junit.jupiter.api.extension.TestInstantiationException: TestInstanceFactory [io.quarkus.test.junit.QuarkusTestExtension] failed to instantiate test class [org.apache.camel.quarkus.component.http.server.it.PlatformHttpTest] at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestInstanceFactory(ClassBasedTestDescriptor.java:298) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateTestClass(ClassBasedTestDescriptor.java:273) at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.instantiateTestClass(ClassTestDescriptor.java:70) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:256) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$2(ClassBasedTestDescriptor.java:250) at java.util.Optional.orElseGet(Optional.java:267) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$3(ClassBasedTestDescriptor.java:249) at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:29) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:106) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:105) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:69) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$1(NodeTestTask.java:107) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:107) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:75) at java.util.ArrayList.forEach(ArrayList.java:1257) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at java.util.ArrayList.forEach(ArrayList.java:1257) at org.junit.platform
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r324288580 ## File path: extensions/platform-http/component/src/main/java/org/apache/camel/component/http/server/PlatformHttpComponent.java ## @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.http.server; + +import java.util.Map; +import java.util.Set; + +import org.apache.camel.CamelContext; +import org.apache.camel.Endpoint; +import org.apache.camel.component.http.server.spi.Method; +import org.apache.camel.support.DefaultComponent; + +public class PlatformHttpComponent extends DefaultComponent { + +public PlatformHttpComponent() { +super(); +} + +public PlatformHttpComponent(CamelContext context) { +super(context); +} + +@Override +protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception { +final String[] remainingParts = remaining.split(":"); +if (remainingParts.length != 2) { +throw new IllegalArgumentException("Expected two segments delimited by ':'; found " + remaining); +} +final Set methods = Method.parseList(remainingParts[0]); +final String path = remainingParts[1]; +return new PlatformHttpEndpoint(uri, this, methods, path); Review comment: Let's allow methods before the path and also as an uriParam to have both good ergonomy and compatibilty with the older components. So all of the following variants would yeld the same result: ``` platform-http:/path?httpMethodRestrict=GET,POST platform-http:GET:/path?httpMethodRestrict=POST platform-http:GET,POST:/path ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r324280445 ## File path: extensions/platform-http/component/pom.xml ## @@ -0,0 +1,57 @@ + + +http://maven.apache.org/POM/4.0.0"; + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd";> +4.0.0 + +org.apache.camel.quarkus +camel-quarkus-platform-http-parent +0.1.1-SNAPSHOT +../pom.xml + + +camel-quarkus-platform-http-component +Camel Quarkus :: Platform HTTP :: Component + + + + +org.apache.camel.quarkus +camel-quarkus-bom +${project.version} +pom +import + + + + + + +org.apache.camel +camel-support + + +org.apache.camel +spi-annotations + + Review comment: Do we need those while the component is hosted here? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r32413 ## File path: extensions/platform-http/component/src/main/java/org/apache/camel/component/http/server/spi/Method.java ## @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.http.server.spi; + +import java.util.Arrays; +import java.util.Collections; +import java.util.Locale; +import java.util.Set; +import java.util.TreeSet; + +/** + * An HTTP method. + */ +public enum Method { Review comment: Actually, depending on `camel-http-common` and excluding the servlet could be an option. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r324184251 ## File path: extensions/platform-http/component/src/main/java/org/apache/camel/component/http/server/PlatformHttpComponent.java ## @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.http.server; + +import java.util.Map; +import java.util.Set; + +import org.apache.camel.CamelContext; +import org.apache.camel.Endpoint; +import org.apache.camel.component.http.server.spi.Method; +import org.apache.camel.support.DefaultComponent; + +public class PlatformHttpComponent extends DefaultComponent { + +public PlatformHttpComponent() { +super(); +} + +public PlatformHttpComponent(CamelContext context) { +super(context); +} + +@Override +protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception { +final String[] remainingParts = remaining.split(":"); +if (remainingParts.length != 2) { +throw new IllegalArgumentException("Expected two segments delimited by ':'; found " + remaining); +} +final Set methods = Method.parseList(remainingParts[0]); +final String path = remainingParts[1]; +return new PlatformHttpEndpoint(uri, this, methods, path); Review comment: You propose more typing but less learning for those who know the older Camel components. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r324181915 ## File path: extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/http/server/QuarkusPlatformHttpEngine.java ## @@ -0,0 +1,317 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.http.server; + +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.inject.Named; + +import io.vertx.core.MultiMap; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.http.HttpServerResponse; +import io.vertx.ext.web.Route; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.RoutingContext; + +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.apache.camel.NoTypeConversionAvailableException; +import org.apache.camel.TypeConversionException; +import org.apache.camel.TypeConverter; +import org.apache.camel.component.http.server.PlatformHttpConstants; +import org.apache.camel.component.http.server.spi.HttpEndpointSpec; +import org.apache.camel.component.http.server.spi.Method; +import org.apache.camel.component.http.server.spi.PlatformHttpEngine; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.support.DefaultMessage; +import org.apache.camel.support.ExchangeHelper; +import org.apache.camel.support.MessageHelper; +import org.apache.camel.support.ObjectHelper; +import org.jboss.logging.Logger; + +@ApplicationScoped +@Named(PlatformHttpConstants.PLATFORM_HTTP_ENGINE_NAME) +public class QuarkusPlatformHttpEngine implements PlatformHttpEngine { Review comment: Why is wiring with build steps better? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service
ppalaga commented on a change in pull request #201: Fix #184 Leverage platform http service URL: https://github.com/apache/camel-quarkus/pull/201#discussion_r324181581 ## File path: extensions/platform-http/component/src/main/java/org/apache/camel/component/http/server/spi/Method.java ## @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.http.server.spi; + +import java.util.Arrays; +import java.util.Collections; +import java.util.Locale; +import java.util.Set; +import java.util.TreeSet; + +/** + * An HTTP method. + */ +public enum Method { Review comment: Yeah, `camel-http-common` currently depends on servlet, which we definitely do not want here. Splitting it and depending on the servlet-less part might be an option. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services