feat: config templates #53, #34, #33

This commit is contained in:
0xJacky 2023-01-05 13:46:42 +08:00
parent 594c61a0ff
commit f5a2a634a1
No known key found for this signature in database
GPG key ID: B6E4A6E4A561BAF0
21 changed files with 420 additions and 96 deletions

View file

@ -13,6 +13,10 @@ const (
Upstream = "upstream"
)
func (s *NgxServer) ParseServer(directive gonginx.IDirective) {
s.parseServer(directive)
}
func (s *NgxServer) parseServer(directive gonginx.IDirective) {
if directive.GetBlock() == nil {
return
@ -36,7 +40,9 @@ func (s *NgxServer) parseServer(directive gonginx.IDirective) {
}
}
}
func (l *NgxLocation) ParseLocation(directive gonginx.IDirective, deep int) {
l.parseLocation(directive, deep)
}
func (l *NgxLocation) parseLocation(directive gonginx.IDirective, deep int) {
if directive.GetBlock() == nil {
return
@ -52,6 +58,10 @@ func (l *NgxLocation) parseLocation(directive gonginx.IDirective, deep int) {
}
}
func (d *NgxDirective) ParseDirective(directive gonginx.IDirective, deep int) {
d.parseDirective(directive, deep)
}
func (d *NgxDirective) parseDirective(directive gonginx.IDirective, deep int) {
if directive.GetBlock() != nil {
d.Params += directive.GetName() + " "
@ -134,6 +144,7 @@ func parse(block gonginx.IBlock, ngxConfig *NgxConfig) {
ngxConfig.parseCustom(v)
}
}
ngxConfig.Custom = FmtCode(ngxConfig.Custom)
}
func ParseNgxConfigByContent(content string) (ngxConfig *NgxConfig) {