mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
42 lines
923 B
Go
42 lines
923 B
Go
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("==========================")
|
|
}
|
|
}
|
|
|
|
}
|