mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 06:47:20 +08:00
34 lines
729 B
Go
34 lines
729 B
Go
package bootstrap
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
|
|
"github.com/TheTNB/panel/internal/http/middleware"
|
|
"github.com/TheTNB/panel/internal/panel"
|
|
"github.com/TheTNB/panel/internal/plugin"
|
|
"github.com/TheTNB/panel/internal/route"
|
|
)
|
|
|
|
func initHttp() {
|
|
panel.Http = chi.NewRouter()
|
|
|
|
// add middleware
|
|
panel.Http.Use(middleware.GlobalMiddleware()...)
|
|
|
|
// add route
|
|
route.Http(panel.Http)
|
|
plugin.Boot(panel.Http)
|
|
|
|
server := &http.Server{
|
|
Addr: panel.Conf.MustString("http.address"),
|
|
Handler: http.AllowQuerySemicolons(panel.Http),
|
|
MaxHeaderBytes: 2048 << 20,
|
|
}
|
|
if err := server.ListenAndServe(); err != nil {
|
|
panic(fmt.Sprintf("failed to start http server: %v", err))
|
|
}
|
|
}
|