🚚 Update config fields

This commit is contained in:
LittleSheep 2024-02-14 15:22:24 +08:00
parent 90e7b03975
commit e158cb8819
2 changed files with 6 additions and 5 deletions

View File

@ -1,10 +1,11 @@
package hypertext package hypertext
import ( import (
"github.com/spf13/viper"
"math/rand" "math/rand"
"regexp" "regexp"
"github.com/spf13/viper"
"code.smartsheep.studio/goatworks/roadsign/pkg/navi" "code.smartsheep.studio/goatworks/roadsign/pkg/navi"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"github.com/samber/lo" "github.com/samber/lo"
@ -20,13 +21,13 @@ func ProxiesHandler(ctx *fiber.Ctx) error {
for _, region := range navi.R.Regions { for _, region := range navi.R.Regions {
// Matching rules // Matching rules
for _, location := range region.Locations { for _, location := range region.Locations {
if !lo.Contains(location.Host, host) { if !lo.Contains(location.Hosts, host) {
continue continue
} }
if !func() bool { if !func() bool {
flag := false flag := false
for _, pattern := range location.Path { for _, pattern := range location.Paths {
if ok, _ := regexp.MatchString(pattern, path); ok { if ok, _ := regexp.MatchString(pattern, path); ok {
flag = true flag = true
break break

View File

@ -20,8 +20,8 @@ type Region struct {
type Location struct { type Location struct {
ID string `json:"id" toml:"id"` ID string `json:"id" toml:"id"`
Host []string `json:"host" toml:"host"` Hosts []string `json:"hosts" toml:"hosts"`
Path []string `json:"path" toml:"path"` Paths []string `json:"paths" toml:"paths"`
Queries map[string]string `json:"queries" toml:"queries"` Queries map[string]string `json:"queries" toml:"queries"`
Headers map[string][]string `json:"headers" toml:"headers"` Headers map[string][]string `json:"headers" toml:"headers"`
Destinations []Destination `json:"destinations" toml:"destinations"` Destinations []Destination `json:"destinations" toml:"destinations"`