diff --git a/config/example.toml b/config/example.toml index 45bc836..117371c 100644 --- a/config/example.toml +++ b/config/example.toml @@ -1,12 +1,12 @@ id = "example-region" -[[locations]] -id = "example-websocket" -host = ["localhost:8000"] -path = ["/ws"] -[[locations.destinations]] -id = "example-websocket-destination" -uri = "http://localhost:8765" +# [[locations]] +# id = "example-websocket" +# host = ["localhost:8000"] +# path = ["/ws"] +# [[locations.destinations]] +# id = "example-websocket-destination" +# uri = "http://localhost:8765" # [[locations]] # id = "example-warden" @@ -23,9 +23,9 @@ uri = "http://localhost:8765" # environment = ["PUBLIC_CMS=https://smartsheep.studio"] [[locations]] -id = "example-static" +id = "example" host = ["localhost:8000"] path = ["/"] [[locations.destinations]] -id = "example-static-destination" -uri = "files://test/data" \ No newline at end of file +id = "example-destination" +uri = "http://protocol.smartsheep.studio:20004" \ No newline at end of file diff --git a/pkg/navi/responder.go b/pkg/navi/responder.go index 0a5c250..b6b34a6 100644 --- a/pkg/navi/responder.go +++ b/pkg/navi/responder.go @@ -9,7 +9,6 @@ import ( "github.com/gofiber/fiber/v2/utils" "github.com/rs/zerolog/log" "github.com/samber/lo" - "github.com/spf13/viper" "github.com/valyala/fasthttp" "io/fs" "net/http" @@ -32,10 +31,11 @@ func makeUnifiedResponse(c *fiber.Ctx, dest *Destination) error { } func makeHypertextResponse(c *fiber.Ctx, dest *Destination) error { - timeout := time.Duration(viper.GetInt64("performance.network_timeout")) * time.Millisecond - return proxy.Do(c, dest.MakeUri(c), &fasthttp.Client{ - ReadTimeout: timeout, - WriteTimeout: timeout, + limit := 60 * time.Millisecond + uri := dest.MakeUri(c) + return proxy.Do(c, uri, &fasthttp.Client{ + ReadTimeout: limit, + WriteTimeout: limit, }) } diff --git a/pkg/navi/struct.go b/pkg/navi/struct.go index 3926470..4127918 100644 --- a/pkg/navi/struct.go +++ b/pkg/navi/struct.go @@ -75,9 +75,10 @@ func (v *Destination) MakeUri(ctx *fiber.Ctx) string { path := string(ctx.Request().URI().Path()) hash := string(ctx.Request().URI().Hash()) + protocol := v.GetProtocol() uri, _ := v.GetRawUri() - return uri + path + + return protocol + "://" + uri + path + lo.Ternary(len(queries) > 0, "?"+strings.Join(queries, "&"), "") + lo.Ternary(len(hash) > 0, "#"+hash, "") }