mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-06-18 18:16:26 +00:00
Use upstream in host config
This commit is contained in:
@ -55,7 +55,7 @@ type Model struct {
|
||||
Certificate *certificate.Model `json:"certificate,omitempty"`
|
||||
NginxTemplate *nginxtemplate.Model `json:"nginx_template,omitempty"`
|
||||
User *user.Model `json:"user,omitempty"`
|
||||
Upstream *upstream.Model `json:"upstream,omitempty"`
|
||||
Upstream upstream.Model `json:"upstream,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Model) getByQuery(query string, params []interface{}) error {
|
||||
@ -119,7 +119,7 @@ func (m *Model) Expand(items []string) error {
|
||||
if m.UpstreamID > 0 {
|
||||
var u upstream.Model
|
||||
u, err = upstream.GetByID(m.UpstreamID)
|
||||
m.Upstream = &u
|
||||
m.Upstream = u
|
||||
}
|
||||
|
||||
if util.SliceContainsItem(items, "user") && m.ID > 0 {
|
||||
@ -140,6 +140,12 @@ func (m *Model) Expand(items []string) error {
|
||||
m.NginxTemplate = &templ
|
||||
}
|
||||
|
||||
if util.SliceContainsItem(items, "upstream") && m.UpstreamID > 0 {
|
||||
var ups upstream.Model
|
||||
ups, err = upstream.GetByID(m.UpstreamID)
|
||||
m.Upstream = ups
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@ -171,6 +177,7 @@ func (m *Model) GetTemplate() Template {
|
||||
Status: m.Status,
|
||||
ErrorMessage: m.ErrorMessage,
|
||||
IsDisabled: m.IsDisabled,
|
||||
Upstream: m.Upstream,
|
||||
}
|
||||
|
||||
return t
|
||||
|
@ -1,13 +1,6 @@
|
||||
package host
|
||||
|
||||
type TemplateUpstream struct {
|
||||
Hostname string
|
||||
Port int
|
||||
BalanceMethod string
|
||||
MaxFails int
|
||||
FailTimeout int
|
||||
AdvancedConfig string
|
||||
}
|
||||
import "npm/internal/entity/upstream"
|
||||
|
||||
// Template is the model given to the template parser, converted from the Model
|
||||
type Template struct {
|
||||
@ -34,5 +27,5 @@ type Template struct {
|
||||
AdvancedConfig string
|
||||
Status string
|
||||
ErrorMessage string
|
||||
Upstreams []TemplateUpstream
|
||||
Upstream upstream.Model
|
||||
}
|
||||
|
Reference in New Issue
Block a user