From c0cf47ada4c5bf458957756cdda9f1f1e23a96f6 Mon Sep 17 00:00:00 2001 From: huangrh Date: Wed, 27 Mar 2019 21:20:06 +0800 Subject: [PATCH] [FIX] invalid value for ingress path --- api/handler/gateway_action.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/api/handler/gateway_action.go b/api/handler/gateway_action.go index 28aa13913..1928a529e 100644 --- a/api/handler/gateway_action.go +++ b/api/handler/gateway_action.go @@ -54,7 +54,12 @@ func (g *GatewayAction) AddHTTPRule(req *apimodel.AddHTTPRuleStruct) (string, er ServiceID: req.ServiceID, ContainerPort: req.ContainerPort, Domain: req.Domain, - Path: req.Path, + Path: func() string { + if !strings.HasPrefix(req.Path, "/") { + return "/" + req.Path + } + return req.Path + }(), Header: req.Header, Cookie: req.Cookie, Weight: req.Weight, @@ -164,7 +169,12 @@ func (g *GatewayAction) UpdateHTTPRule(req *apimodel.UpdateHTTPRuleStruct) (stri if req.Domain != "" { rule.Domain = req.Domain } - rule.Path = req.Path + rule.Path = func() string { + if !strings.HasPrefix(req.Path, "/") { + return "/" + req.Path + } + return req.Path + }() rule.Header = req.Header rule.Cookie = req.Cookie rule.Weight = req.Weight