Class GatewayForwarder
java.lang.Object
io.leandev.appfuse.http.gateway.GatewayForwarder
Gateway 轉發器
負責將 HTTP 請求透過 Gateway 轉發到目標服務。 保留原始請求的方法、路徑、參數和內容,但修改目標主機為 Gateway。
使用場景
- API Gateway 架構:統一入口點
- 開發環境代理:本地開發時轉發到遠端服務
- 測試環境:Mock Server 或 Stub Server
轉發邏輯
``` 原始請求: GET https://api.example.com/users?role=admin Gateway: http://localhost:8080轉發後: GET http://localhost:8080/users?role=admin Header: Forwarded-URL: https://api.example.com
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.hc.core5.http.ClassicHttpRequestforward(org.apache.hc.core5.http.ClassicHttpRequest request) 透過 Gateway 轉發請求
-
Field Details
-
FORWARDED_URL_HEADER
-
-
Constructor Details
-
GatewayForwarder
public GatewayForwarder()
-
-
Method Details
-
forward
public org.apache.hc.core5.http.ClassicHttpRequest forward(org.apache.hc.core5.http.ClassicHttpRequest request) throws URISyntaxException 透過 Gateway 轉發請求- Parameters:
request- 原始請求- Returns:
- 轉發後的請求
- Throws:
URISyntaxException- 如果 URI 格式錯誤
-