better host upstream support

This commit is contained in:
Jamie Curnow
2023-01-09 13:18:11 +10:00
parent 0a50672ab6
commit ca4d92d793
6 changed files with 30 additions and 7 deletions

View File

@ -38,6 +38,9 @@ func create(host *Model) (int, error) {
listen_interface,
domain_names,
upstream_id,
proxy_scheme,
proxy_host,
proxy_port,
certificate_id,
access_list_id,
ssl_forced,
@ -62,6 +65,9 @@ func create(host *Model) (int, error) {
:listen_interface,
:domain_names,
:upstream_id,
:proxy_scheme,
:proxy_host,
:proxy_port,
:certificate_id,
:access_list_id,
:ssl_forced,
@ -112,6 +118,9 @@ func update(host *Model) error {
listen_interface = :listen_interface,
domain_names = :domain_names,
upstream_id = :upstream_id,
proxy_scheme = :proxy_scheme,
proxy_host = :proxy_host,
proxy_port = :proxy_port,
certificate_id = :certificate_id,
access_list_id = :access_list_id,
ssl_forced = :ssl_forced,

View File

@ -58,7 +58,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 {
@ -122,7 +122,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 {
@ -146,7 +146,7 @@ func (m *Model) Expand(items []string) error {
if util.SliceContainsItem(items, "upstream") && m.UpstreamID > 0 {
var ups upstream.Model
ups, err = upstream.GetByID(m.UpstreamID)
m.Upstream = ups
m.Upstream = &ups
}
return err
@ -163,6 +163,9 @@ func (m *Model) GetTemplate() Template {
UserID: m.UserID,
Type: m.Type,
NginxTemplateID: m.NginxTemplateID,
ProxyScheme: m.ProxyScheme,
ProxyHost: m.ProxyHost,
ProxyPort: m.ProxyPort,
ListenInterface: m.ListenInterface,
DomainNames: domainNames,
UpstreamID: m.UpstreamID,
@ -180,7 +183,6 @@ func (m *Model) GetTemplate() Template {
Status: m.Status,
ErrorMessage: m.ErrorMessage,
IsDisabled: m.IsDisabled,
Upstream: m.Upstream,
}
return t

View File

@ -10,6 +10,9 @@ type Template struct {
UserID int
Type string
NginxTemplateID int
ProxyScheme string
ProxyHost string
ProxyPort int
ListenInterface string
DomainNames []string
UpstreamID int