feat: 增加nginx config 格式化工具
This commit is contained in:

committed by
zhengkunwang223

parent
7dad47464d
commit
a1ac689a5e
32
backend/utils/nginx/components/location.go
Normal file
32
backend/utils/nginx/components/location.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package components
|
||||
|
||||
type Location struct {
|
||||
*Directive
|
||||
Modifier string
|
||||
Match string
|
||||
}
|
||||
|
||||
func NewLocation(directive *Directive) *Location {
|
||||
location := &Location{
|
||||
Modifier: "",
|
||||
Match: "",
|
||||
Directive: directive,
|
||||
}
|
||||
if directive.GetBlock() != nil {
|
||||
directive.Comment = directive.GetBlock().GetComment()
|
||||
}
|
||||
|
||||
if len(directive.Parameters) == 0 {
|
||||
panic("no enough parameter for location")
|
||||
}
|
||||
|
||||
if len(directive.Parameters) == 1 {
|
||||
location.Match = directive.Parameters[0]
|
||||
return location
|
||||
} else if len(directive.Parameters) == 2 {
|
||||
location.Modifier = directive.Parameters[0]
|
||||
location.Match = directive.Parameters[1]
|
||||
return location
|
||||
}
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user