mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-12 02:45:49 +02:00
Tokenized nginx config
This commit is contained in:
parent
a3e7c58f53
commit
7abd5ce966
16 changed files with 534 additions and 107 deletions
42
server/test/ngx_conf_parse_test.go
Normal file
42
server/test/ngx_conf_parse_test.go
Normal file
|
@ -0,0 +1,42 @@
|
|||
package test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/0xJacky/Nginx-UI/server/tool/nginx"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNgxConfParse(t *testing.T) {
|
||||
c, err := nginx.ParseNgxConfig("nextcloud_ngx.conf")
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Println(c.FileName)
|
||||
// directive in root
|
||||
fmt.Println("Upstream")
|
||||
for _, u := range c.Upstreams {
|
||||
fmt.Println("upstream name", u.Name)
|
||||
fmt.Printf("comments\n%v", u.Comments)
|
||||
for _, d := range u.Directives {
|
||||
fmt.Println("u.Directives.d", d)
|
||||
}
|
||||
}
|
||||
fmt.Println("==========================")
|
||||
fmt.Println("Servers")
|
||||
for _, s := range c.Servers {
|
||||
fmt.Printf("comments\n%v", s.Comments)
|
||||
for _, d := range s.Directives {
|
||||
fmt.Println(d)
|
||||
}
|
||||
// locations
|
||||
for _, location := range s.Locations {
|
||||
fmt.Printf("comments\n%v", location.Comments)
|
||||
fmt.Println("path", location.Path)
|
||||
fmt.Println("content", location.Content)
|
||||
fmt.Println("==========================")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue