mirror of
https://github.com/hanzoai/status.git
synced 2026-10-30 18:21:48 +00:00
zip's registration is a verb method on the group, so a route that is not a typed operation says which method it answers with. The security package's own two-method router goes with it: it existed so both the app and a sub-router could satisfy one name, and restating a routing surface is what let the two disagree — the methods it named no longer exist. The app spells itself as a group, which registers at exactly the paths it did. The toolchain and the pin move together, because below zip v1.36.50 the JSON encoder was selected on a build tag: a repo whose go directive rises first writes a wire that is neither the old release's nor the new one's until the pin catches up. metrics_test.go still does not compile, before and after: it compares a metric registry against a gatherer from a different metrics library, so the two Gather signatures disagree. That is its own change. Co-authored-by: Hanzo Dev <[email protected]>
51 lines
1.3 KiB
Go
51 lines
1.3 KiB
Go
package controller
|
|
|
|
import (
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/TwiN/logr"
|
|
fiber "github.com/zap-proto/fiber/v3"
|
|
"github.com/zap-proto/zip"
|
|
"hanzo.ai/status/api"
|
|
"hanzo.ai/status/config"
|
|
)
|
|
|
|
var (
|
|
app *zip.App
|
|
)
|
|
|
|
// Handle creates the router and starts the server
|
|
func Handle(cfg *config.Config) {
|
|
api := api.New(cfg)
|
|
app = api.Router()
|
|
server := app.Fiber().Server()
|
|
server.ReadTimeout = 15 * time.Second
|
|
server.WriteTimeout = 15 * time.Second
|
|
server.IdleTimeout = 15 * time.Second
|
|
if os.Getenv("ROUTER_TEST") == "true" {
|
|
return
|
|
}
|
|
logr.Info("[controller.Handle] Listening on " + cfg.Web.SocketAddress())
|
|
// TLS is a value in the listen config, not a second Listen method. zip's own
|
|
// Listen carries neither a TLS nor a dual-stack knob, so this is the one
|
|
// place the app escapes to the underlying fiber listener.
|
|
listenConfig := fiber.ListenConfig{ListenerNetwork: fiber.NetworkTCP}
|
|
if cfg.Web.HasTLS() {
|
|
listenConfig.CertFile = cfg.Web.TLS.CertificateFile
|
|
listenConfig.CertKeyFile = cfg.Web.TLS.PrivateKeyFile
|
|
}
|
|
if err := app.Fiber().Listen(cfg.Web.SocketAddress(), listenConfig); err != nil {
|
|
logr.Fatalf("[controller.Handle] %s", err.Error())
|
|
}
|
|
logr.Info("[controller.Handle] Server has shut down successfully")
|
|
}
|
|
|
|
// Shutdown stops the server
|
|
func Shutdown() {
|
|
if app != nil {
|
|
_ = app.Fiber().Shutdown()
|
|
app = nil
|
|
}
|
|
}
|