feat(proxy-route): allow disabling HTTP/2 per route

This commit is contained in:
ryan
2026-10-07 10:30:16 +08:00
parent 0bebca2990
commit 7ad25f61aa
20 changed files with 100 additions and 14 deletions
@@ -113,6 +113,14 @@ func populateProxyRouteFields(
route.UpstreamType = upstreamType
}
func applyProxyRouteHTTP2(route *model.ProxyRoute, input Input) {
if input.EnableHTTP2 != nil {
route.EnableHTTP2 = *input.EnableHTTP2
} else if route.ID == 0 {
route.EnableHTTP2 = true
}
}
func applyProxyRouteUpstreamType(ctx context.Context, route *model.ProxyRoute, upstreamType string, input Input) error {
switch upstreamType {
case proxyRouteUpstreamTypeTunnel:
@@ -35,6 +35,7 @@ type Input struct {
Upstreams []string `json:"upstreams"`
Enabled bool `json:"enabled"`
EnableHTTPS bool `json:"enable_https"`
EnableHTTP2 *bool `json:"enable_http2"`
RedirectHTTP bool `json:"redirect_http"`
LimitConnPerServer int `json:"limit_conn_per_server"`
LimitConnPerIP int `json:"limit_conn_per_ip"`
@@ -68,6 +69,7 @@ type View struct {
UpstreamList []string `json:"upstream_list"`
Enabled bool `json:"enabled"`
EnableHTTPS bool `json:"enable_https"`
EnableHTTP2 bool `json:"enable_http2"`
RedirectHTTP bool `json:"redirect_http"`
LimitConnPerServer int `json:"limit_conn_per_server"`
LimitConnPerIP int `json:"limit_conn_per_ip"`
@@ -310,6 +312,7 @@ func buildProxyRoute(ctx context.Context, route *model.ProxyRoute, input Input)
if route == nil {
route = &model.ProxyRoute{}
}
applyProxyRouteHTTP2(route, input)
populateProxyRouteFields(
route,
input,
@@ -381,6 +384,7 @@ func buildProxyRouteView(ctx context.Context, route *model.ProxyRoute) (*View, e
UpstreamList: upstreams,
Enabled: route.Enabled,
EnableHTTPS: route.EnableHTTPS,
EnableHTTP2: route.EnableHTTP2,
RedirectHTTP: route.RedirectHTTP,
LimitConnPerServer: route.LimitConnPerServer,
LimitConnPerIP: route.LimitConnPerIP,