feat: host-based routing in proxy

This commit is contained in:
2023-03-22 18:15:22 +01:00
parent 8ada7e3b84
commit cd796fff89
10 changed files with 165 additions and 72 deletions

View File

@ -14,11 +14,23 @@
"address": {
"type": "string"
},
"target": {
"type": "string"
"mappings": {
"type": "array",
"items": {
"type": "object",
"properties": {
"hostPattern": {
"type": "string"
},
"target": {
"type": "string"
}
},
"required": ["hostPattern", "target"]
}
}
},
"required": ["address", "target"],
"required": ["address", "mappings"],
"additionalProperties": false
}
}

View File

@ -12,8 +12,13 @@ type Spec struct {
}
type ProxyEntry struct {
Address string `json:"address"`
Target string `json:"target"`
Address string `json:"address"`
Mappings []ProxyMapping `json:"mappings"`
}
type ProxyMapping struct {
HostPattern string `json:"hostPattern"`
Target string `json:"target"`
}
func (s *Spec) SpecName() spec.Name {

View File

@ -4,7 +4,12 @@
"proxies": {
"cadoles.com": {
"address": ":3003",
"target": "https://www.cadoles.com",
"mappings": [
{
"hostPattern": "localhost:3003",
"target": "https://www.cadoles.com"
}
],
"foo": "bar"
}
}

View File

@ -4,7 +4,12 @@
"proxies": {
"cadoles.com": {
"address": ":3003",
"target": "https://www.cadoles.com"
"mappings": [
{
"hostPattern": "localhost:3003",
"target": "https://www.cadoles.com"
}
]
}
}
},