🐛 Bug fixes
Some checks are pending
release-nightly / build-docker (push) Waiting to run

This commit is contained in:
LittleSheep 2024-01-26 15:31:19 +08:00
parent 72d23c35f5
commit 302491741f
4 changed files with 20 additions and 29 deletions

View File

@ -8,24 +8,24 @@ path = ["/ws"]
id = "example-websocket-destination" id = "example-websocket-destination"
uri = "http://localhost:8765" uri = "http://localhost:8765"
[[locations]] # [[locations]]
id = "example-warden" # id = "example-warden"
host = ["localhost:4321"] # host = ["localhost:4321"]
path = ["/"] # path = ["/"]
[[locations.destinations]] # [[locations.destinations]]
id = "example-warden-destination" # id = "example-warden-destination"
uri = "http://localhost:4321" # uri = "http://localhost:4321"
[[applications]] # [[applications]]
id = "example-warden-app" # id = "example-warden-app"
workdir = "test/data/warden" # workdir = "test/data/warden"
command = ["node", "dist/server/entry.mjs"] # command = ["node", "dist/server/entry.mjs"]
environment = ["PUBLIC_CMS=https://smartsheep.studio"] # environment = ["PUBLIC_CMS=https://smartsheep.studio"]
[[locations]] [[locations]]
id = "example-static" id = "example-static"
host = ["localhost:8000"] host = ["localhost:8000"]
path = ["/roadsign"] path = ["/"]
[[locations.destinations]] [[locations.destinations]]
id = "example-static-destination" id = "example-static-destination"
uri = "files://test/data" uri = "files://test/data"

View File

@ -24,7 +24,7 @@ func InitServer() *fiber.App {
BodyLimit: viper.GetInt("hypertext.limitation.max_body_size"), BodyLimit: viper.GetInt("hypertext.limitation.max_body_size"),
}) })
if viper.GetBool("performance.request_logging") { if viper.GetBool("telemetry.request_logging") {
app.Use(logger.New(logger.Config{ app.Use(logger.New(logger.Config{
Output: log.Logger, Output: log.Logger,
Format: "[Proxies] [${time}] ${status} - ${latency} ${method} ${path}\n", Format: "[Proxies] [${time}] ${status} - ${latency} ${method} ${path}\n",
@ -47,7 +47,7 @@ func RunServer(app *fiber.App, ports []string, securedPorts []string, pem string
for _, port := range ports { for _, port := range ports {
port := port port := port
go func() { go func() {
if viper.GetBool("hypertext.certificate.redirect") { if viper.GetBool("hypertext.redirect_to_https") {
redirector := fiber.New(fiber.Config{ redirector := fiber.New(fiber.Config{
AppName: "RoadSign", AppName: "RoadSign",
ServerHeader: "RoadSign", ServerHeader: "RoadSign",

View File

@ -24,16 +24,12 @@ func makeUnifiedResponse(c *fiber.Ctx, dest *Destination) error {
// Handle websocket // Handle websocket
return makeWebsocketResponse(c, dest) return makeWebsocketResponse(c, dest)
} else { } else {
_, queries := dest.GetRawUri() // TODO Impl SSE with https://github.com/gofiber/recipes/blob/master/sse/main.go
if len(queries.Get("sse")) > 0 {
// Handle server-side event
return makeSeverSideEventResponse(c, dest)
} else {
// Handle normal http request // Handle normal http request
return makeHypertextResponse(c, dest) return makeHypertextResponse(c, dest)
} }
} }
}
func makeHypertextResponse(c *fiber.Ctx, dest *Destination) error { func makeHypertextResponse(c *fiber.Ctx, dest *Destination) error {
timeout := time.Duration(viper.GetInt64("performance.network_timeout")) * time.Millisecond timeout := time.Duration(viper.GetInt64("performance.network_timeout")) * time.Millisecond
@ -98,11 +94,6 @@ func makeWebsocketResponse(c *fiber.Ctx, dest *Destination) error {
}) })
} }
func makeSeverSideEventResponse(c *fiber.Ctx, dest *Destination) error {
// TODO Impl SSE with https://github.com/gofiber/recipes/blob/master/sse/main.go
return fiber.NewError(fiber.StatusNotImplemented, "Server-side-events was not available now.")
}
func makeFileResponse(c *fiber.Ctx, dest *Destination) error { func makeFileResponse(c *fiber.Ctx, dest *Destination) error {
uri, queries := dest.GetRawUri() uri, queries := dest.GetRawUri()
root := http.Dir(uri) root := http.Dir(uri)

View File

@ -29,7 +29,7 @@ func InitSideload() *fiber.App {
BodyLimit: viper.GetInt("hypertext.limitation.max_body_size"), BodyLimit: viper.GetInt("hypertext.limitation.max_body_size"),
}) })
if viper.GetBool("performance.request_logging") { if viper.GetBool("telemetry.request_logging") {
app.Use(logger.New(logger.Config{ app.Use(logger.New(logger.Config{
Output: log.Logger, Output: log.Logger,
Format: "[Sideload] [${time}] ${status} - ${latency} ${method} ${path}\n", Format: "[Sideload] [${time}] ${status} - ${latency} ${method} ${path}\n",