mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-12 19:05:55 +02:00
refactor: project structure
This commit is contained in:
parent
eab95dd091
commit
ee1f67b3cd
155 changed files with 269 additions and 261 deletions
|
@ -1,49 +0,0 @@
|
|||
package nginx
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/tufanbarisyildirim/gonginx"
|
||||
"github.com/tufanbarisyildirim/gonginx/parser"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNgxConfParse(t *testing.T) {
|
||||
p, err := parser.NewParser("conf/nextcloud_ngx.conf")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
n := p.Parse()
|
||||
|
||||
fn(n.Block, 0)
|
||||
|
||||
c, err := ParseNgxConfig("conf/nextcloud_ngx.conf")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
fmt.Println(c)
|
||||
c, err = ParseNgxConfig("conf/test.conf")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
fmt.Println(c)
|
||||
}
|
||||
|
||||
func fn(block gonginx.IBlock, deep int) {
|
||||
if block == nil {
|
||||
return
|
||||
}
|
||||
for _, v := range block.GetDirectives() {
|
||||
if len(v.GetComment()) > 0 {
|
||||
for _, c := range v.GetComment() {
|
||||
fmt.Println(strings.Repeat("\t", deep), c)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println(fmt.Sprintf("%s%s %s", strings.Repeat("\t", deep), v.GetName(), strings.Join(v.GetParameters(), " ")))
|
||||
fn(v.GetBlock(), deep+1)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue