1Panel/backend/utils/nginx/components/config.go
2022-11-24 16:08:57 +08:00

38 lines
829 B
Go

package components
type Config struct {
*Block
FilePath string
}
func (c *Config) FindDirectives(directiveName string) []IDirective {
return c.Block.FindDirectives(directiveName)
}
func (c *Config) FindUpstreams() []*Upstream {
var upstreams []*Upstream
directives := c.Block.FindDirectives("upstream")
for _, directive := range directives {
upstreams = append(upstreams, directive.(*Upstream))
}
return upstreams
}
func (c *Config) FindServers() []*Server {
var servers []*Server
directives := c.Block.FindDirectives("server")
for _, directive := range directives {
servers = append(servers, directive.(*Server))
}
return servers
}
func (c *Config) FindHttp() *Http {
var http *Http
directives := c.Block.FindDirectives("http")
if len(directives) > 0 {
http = directives[0].(*Http)
}
return http
}