Enhance REST provider
This commit is contained in:
parent
48d98dcf45
commit
51486b18fa
5 changed files with 94 additions and 40 deletions
|
@ -30,7 +30,7 @@ type Configuration struct {
|
|||
|
||||
// TLSConfiguration contains all the configuration parameters of a TLS connection.
|
||||
type TLSConfiguration struct {
|
||||
Certificates []*tls.CertAndStores `json:"-" toml:"certificates,omitempty" yaml:"certificates,omitempty" label:"-"`
|
||||
Certificates []*tls.CertAndStores `json:"certificates,omitempty" toml:"certificates,omitempty" yaml:"certificates,omitempty" label:"-"`
|
||||
Options map[string]tls.Options `json:"options,omitempty" toml:"options,omitempty" yaml:"options,omitempty"`
|
||||
Stores map[string]tls.Store `json:"stores,omitempty" toml:"stores,omitempty" yaml:"stores,omitempty"`
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ func (p *Provider) Append(systemRouter *mux.Router) {
|
|||
return
|
||||
}
|
||||
|
||||
configuration := new(dynamic.HTTPConfiguration)
|
||||
configuration := new(dynamic.Configuration)
|
||||
body, _ := ioutil.ReadAll(request.Body)
|
||||
|
||||
if err := json.Unmarshal(body, configuration); err != nil {
|
||||
|
@ -57,9 +57,7 @@ func (p *Provider) Append(systemRouter *mux.Router) {
|
|||
return
|
||||
}
|
||||
|
||||
p.configurationChan <- dynamic.Message{ProviderName: "rest", Configuration: &dynamic.Configuration{
|
||||
HTTP: configuration,
|
||||
}}
|
||||
p.configurationChan <- dynamic.Message{ProviderName: "rest", Configuration: configuration}
|
||||
if err := templatesRenderer.JSON(response, http.StatusOK, configuration); err != nil {
|
||||
log.WithoutContext().Error(err)
|
||||
}
|
||||
|
|
|
@ -175,8 +175,22 @@ func (s *Server) preLoadConfiguration(configMsg dynamic.Message) {
|
|||
|
||||
logger := log.WithoutContext().WithField(log.ProviderName, configMsg.ProviderName)
|
||||
if log.GetLevel() == logrus.DebugLevel {
|
||||
jsonConf, _ := json.Marshal(configMsg.Configuration)
|
||||
logger.Debugf("Configuration received from provider %s: %s", configMsg.ProviderName, string(jsonConf))
|
||||
copyConf := configMsg.Configuration.DeepCopy()
|
||||
if copyConf.TLS != nil {
|
||||
copyConf.TLS.Certificates = nil
|
||||
|
||||
for _, v := range copyConf.TLS.Stores {
|
||||
v.DefaultCertificate = nil
|
||||
}
|
||||
}
|
||||
|
||||
jsonConf, err := json.Marshal(copyConf)
|
||||
if err != nil {
|
||||
logger.Errorf("Could not marshal dynamic configuration: %v", err)
|
||||
logger.Debugf("Configuration received from provider %s: [struct] %#v", configMsg.ProviderName, copyConf)
|
||||
} else {
|
||||
logger.Debugf("Configuration received from provider %s: %s", configMsg.ProviderName, string(jsonConf))
|
||||
}
|
||||
}
|
||||
|
||||
if isEmptyConfiguration(configMsg.Configuration) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue