将REST与http连接时出现内容解码问题

时间:2019-05-03 20:08:17

标签: apache-camel

我正在尝试将REST路由桥接到上游http服务。从chrome浏览时,解码内容存在问题-ERR_CONTENT_DECODING_FAILED。我认为这与gzip有关。我是新来的Apache骆驼,所以我不确定哪里出了问题。

这是路线:

What went wrong:
A problem occurred evaluating project ':expo-react-native-adapter'.
Project with path ':expo-core' could not be found in project ':expo-react-native-adapter'.

Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.1/userguide/command_line_interface.html#sec:command_line_warnings

我如何成功从8080的服务中返回内容?

1 个答案:

答案 0 :(得分:0)

我做了一些阅读,发现我没有正确使用 bindingMode https://camel.apache.org/rest-dsl.html的“绑定到POJO”部分应为所有遇到此问题的新手解释一切。在我的特定情况下,解决方法只是从其余配置中删除 bindingMode 。在我的示例中这是安全的,因为我不需要解组所有传入的消息-所有GET。

工作代码:

class RestRouteBuilder : RouteBuilder() {

    override fun configure() {
        restConfiguration().apply {
            component = "undertow"
            port = "8082"
            scheme = "http"
        }

        rest("/airlines")
            .get("/").produces("application/json").to("undertow:http://localhost:8080/airlines?bridgeEndpoint=true")
    }
}