diff options
Diffstat (limited to 'src/daq/s5proxy')
-rw-r--r-- | src/daq/s5proxy/sample.json | 2 | ||||
-rw-r--r-- | src/daq/s5proxy/src/s5proxy/config.go | 31 | ||||
-rw-r--r-- | src/daq/s5proxy/src/s5proxy/proxy.go | 4 |
3 files changed, 20 insertions, 17 deletions
diff --git a/src/daq/s5proxy/sample.json b/src/daq/s5proxy/sample.json index 5200bca..0851e7e 100644 --- a/src/daq/s5proxy/sample.json +++ b/src/daq/s5proxy/sample.json @@ -30,7 +30,7 @@ { "op": "add", "header": "Cache-Control", "value": "max-age=0" }, { "op": "time", "header": "Expires", "value": "-1s" } ], - "locations": { + "backends": { "/hls/": { "connect": "http://nginx-streamer-emc-01:8000" }, "/dash/": { "connect": "http://nginx-streamer-emc-01:8000" } }, diff --git a/src/daq/s5proxy/src/s5proxy/config.go b/src/daq/s5proxy/src/s5proxy/config.go index 12a610f..03047b0 100644 --- a/src/daq/s5proxy/src/s5proxy/config.go +++ b/src/daq/s5proxy/src/s5proxy/config.go @@ -216,6 +216,15 @@ type SFiveConf struct { } //********************************************* +//********** Backend + +type Backend struct { + ConnectAddr string `json:"connect"` + RequestHeader []HeaderOperation `json:"request_header"` + ResponseHeader []HeaderOperation `json:"response_header"` +} + +//********************************************* //********** Configuration type Config struct { @@ -224,14 +233,8 @@ type Config struct { Redirect2HTTPS RedirectCode `json:"redirect2https"` TLS tlsconfig.TLSConfig `json:"tls"` - ConnectAddr string `json:"connect"` - RequestHeader []HeaderOperation `json:"request_header"` - ResponseHeader []HeaderOperation `json:"response_header"` - Locations map[string]struct { - ConnectAddr string `json:"connect"` - RequestHeader []HeaderOperation `json:"request_header"` - ResponseHeader []HeaderOperation `json:"response_header"` - } `json:"locations"` + Backend + Backends map[string]Backend `json:"backends"` SFive SFiveConf `json:"sfive"` } @@ -268,18 +271,18 @@ func readConfig(configfile string) (conf *Config, err error) { } } - for k, v := range conf.Locations { - tmp := v - if v.ConnectAddr == "" { + for location, backend := range conf.Backends { + tmp := backend + if backend.ConnectAddr == "" { tmp.ConnectAddr = conf.ConnectAddr } - if len(v.RequestHeader) == 0 { + if len(backend.RequestHeader) == 0 { tmp.RequestHeader = conf.RequestHeader } - if len(v.ResponseHeader) == 0 { + if len(backend.ResponseHeader) == 0 { tmp.ResponseHeader = conf.ResponseHeader } - conf.Locations[k] = tmp + conf.Backends[location] = tmp } return diff --git a/src/daq/s5proxy/src/s5proxy/proxy.go b/src/daq/s5proxy/src/s5proxy/proxy.go index 0e4fe21..d47fa60 100644 --- a/src/daq/s5proxy/src/s5proxy/proxy.go +++ b/src/daq/s5proxy/src/s5proxy/proxy.go @@ -150,8 +150,8 @@ func NewProxy(conf *Config, stats *Stats) (p *Proxy, err error) { p = &Proxy{conf: conf, stats: stats} p.mux = http.NewServeMux() - for location, l := range conf.Locations { - p.installProxyHandler(location, l.ConnectAddr, l.RequestHeader, l.ResponseHeader) + for location, backend := range conf.Backends { + p.installProxyHandler(location, backend.ConnectAddr, backend.RequestHeader, backend.ResponseHeader) } p.installProxyHandler("/", conf.ConnectAddr, conf.RequestHeader, conf.ResponseHeader) p.srv = &http.Server{Handler: p.mux} |