Last active
August 23, 2021 21:55
-
-
Save luszczynski/d03d1cb4fb1865d4d0e6b9dbe559abd7 to your computer and use it in GitHub Desktop.
Camel K Java class to use in the 3scale Gateway (APICast) Camel Policy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// kamel run ProxyRoute.java --dev | |
import java.util.Locale; | |
import org.apache.camel.Exchange; | |
import org.apache.camel.Message; | |
import org.apache.camel.builder.RouteBuilder; | |
public class ProxyRoute extends RouteBuilder { | |
@Override | |
public void configure() throws Exception { | |
from("netty-http:proxy://0.0.0.0:8080") | |
.log("recebendo request") | |
.process(ProxyRoute::uppercase) | |
.toD("netty-http:" | |
+ "${headers." + Exchange.HTTP_SCHEME + "}://" | |
+ "${headers." + Exchange.HTTP_HOST + "}:" | |
+ "${headers." + Exchange.HTTP_PORT + "}" | |
+ "${headers." + Exchange.HTTP_PATH + "}") | |
.process(ProxyRoute::uppercase); | |
} | |
public static void uppercase(final Exchange exchange) { | |
final Message message = exchange.getIn(); | |
final String body = message.getBody(String.class); | |
message.setBody(body.toUpperCase(Locale.US)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment