我正在嘗試向我的駱駝休息路線添加授權標頭。這是路線: restConfiguration().producerComponent("http4").host(env.getProperty("my.rest.host"));
from(env.getProperty("in.route"))
.to(env.getProperty("rest.endpoint.path"))我熟悉“非駱駝”程序,例如使用 RestTemplate,您可以在其中執(zhí)行類似 setHeader("Authorisation", "Bearer myJWT...") 的操作。我期待駱駝也能有同樣簡單的東西。但到目前為止我的搜索還沒有成功!有人可以給我提示嗎?
1 回答

qq_笑_17
TA貢獻1818條經(jīng)驗 獲得超7個贊
使用交換和更新標題
from(env.getProperty("in.route")).process(new Processor {
public void process(Exchange exchange) throws Exception {
//you token logic
String token = "--token logic-------"
exchange.getIn().setHeader("Authorization", token)
}
}).to(env.getProperty("rest.endpoint.path"))
添加回答
舉報
0/150
提交
取消