mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-12-04 04:38:04 +08:00
[REV] Update lds header setting support
This commit is contained in:
parent
517e69133e
commit
d0eb4fd34c
@ -135,7 +135,8 @@ type PieceHTTPRoutes struct {
|
|||||||
TimeoutMS int `json:"timeout_ms"`
|
TimeoutMS int `json:"timeout_ms"`
|
||||||
Prefix string `json:"prefix"`
|
Prefix string `json:"prefix"`
|
||||||
Cluster string `json:"cluster"`
|
Cluster string `json:"cluster"`
|
||||||
//Headers []*PieceHeader `json:"headers"`
|
//Headers []PieceHeader `json:"headers"`
|
||||||
|
Headers interface{} `json:"headers"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//PieceHeader PieceHeader
|
//PieceHeader PieceHeader
|
||||||
|
@ -279,12 +279,19 @@ func (d *DiscoverAction) DiscoverListeners(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
headers := d.ToolsGetRouterItem(
|
||||||
|
destServiceAlias,
|
||||||
|
node_model.HEADERS, options)
|
||||||
|
if headers == nil {
|
||||||
|
mm := make(map[string]string)
|
||||||
|
mm["name"] = "with_empty_header"
|
||||||
|
headers = []map[string]string{mm}
|
||||||
|
}
|
||||||
prs := &node_model.PieceHTTPRoutes{
|
prs := &node_model.PieceHTTPRoutes{
|
||||||
TimeoutMS: 0,
|
TimeoutMS: 0,
|
||||||
Prefix: d.ToolsGetRouterItem(destServiceAlias, node_model.PREFIX, options).(string),
|
Prefix: d.ToolsGetRouterItem(destServiceAlias, node_model.PREFIX, options).(string),
|
||||||
Cluster: fmt.Sprintf("%s_%s_%s_%d", namespace, serviceAlias, destServiceAlias, port),
|
Cluster: fmt.Sprintf("%s_%s_%s_%d", namespace, serviceAlias, destServiceAlias, port),
|
||||||
//Headers: d.ToolsGetRouterItem(destServiceAlias,
|
Headers: headers,
|
||||||
// node_model.HEADERS, &sr).([]*node_model.PieceHeader),
|
|
||||||
}
|
}
|
||||||
pvh := &node_model.PieceHTTPVirtualHost{
|
pvh := &node_model.PieceHTTPVirtualHost{
|
||||||
Name: fmt.Sprintf("%s_%s_%s_%d", namespace, serviceAlias, destServiceAlias, port),
|
Name: fmt.Sprintf("%s_%s_%s_%d", namespace, serviceAlias, destServiceAlias, port),
|
||||||
@ -558,7 +565,22 @@ func (d *DiscoverAction) ToolsGetRouterItem(
|
|||||||
}
|
}
|
||||||
return 3
|
return 3
|
||||||
case node_model.HEADERS:
|
case node_model.HEADERS:
|
||||||
return ""
|
if headers, ok := sr[node_model.HEADERS]; ok {
|
||||||
|
var np []node_model.PieceHeader
|
||||||
|
parents := strings.Split(headers.(string), ";")
|
||||||
|
for _, h := range parents {
|
||||||
|
headers := strings.Split(h, ":")
|
||||||
|
if len(headers) == 2 {
|
||||||
|
ph := node_model.PieceHeader{
|
||||||
|
Name: headers[0],
|
||||||
|
Value: headers[1],
|
||||||
|
}
|
||||||
|
np = append(np, ph)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return np
|
||||||
|
}
|
||||||
|
return nil
|
||||||
case node_model.DOMAINS:
|
case node_model.DOMAINS:
|
||||||
if domain, ok := sr[node_model.DOMAINS]; ok {
|
if domain, ok := sr[node_model.DOMAINS]; ok {
|
||||||
if destAlias != "" {
|
if destAlias != "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user