Redo router and use chi, implement anchor file
This commit is contained in:
@@ -9,14 +9,14 @@ import (
|
||||
// _ "net/http/pprof" // Register pprof
|
||||
|
||||
"github.com/debridmediamanager/zurg/internal/config"
|
||||
"github.com/debridmediamanager/zurg/internal/router"
|
||||
"github.com/debridmediamanager/zurg/internal/handlers"
|
||||
"github.com/debridmediamanager/zurg/internal/torrent"
|
||||
"github.com/debridmediamanager/zurg/internal/universal"
|
||||
"github.com/debridmediamanager/zurg/pkg/http"
|
||||
"github.com/debridmediamanager/zurg/pkg/logutil"
|
||||
"github.com/debridmediamanager/zurg/pkg/realdebrid"
|
||||
"github.com/debridmediamanager/zurg/pkg/utils"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/panjf2000/ants/v2"
|
||||
)
|
||||
|
||||
@@ -51,10 +51,8 @@ func MainApp(configPath string) {
|
||||
downloadClient := http.NewHTTPClient(config.GetToken(), config.GetRetriesUntilFailed(), 0, config, log.Named("dlclient"))
|
||||
getfile := universal.NewGetFile(downloadClient)
|
||||
|
||||
handler := httprouter.New()
|
||||
handler.RedirectTrailingSlash = false
|
||||
handler.RedirectFixedPath = true
|
||||
router.ApplyRouteTable(handler, getfile, torrentMgr, config, rd, log.Named("router"))
|
||||
router := chi.NewRouter()
|
||||
handlers.AttachHandlers(router, getfile, torrentMgr, config, rd, log.Named("router"))
|
||||
|
||||
// go func() {
|
||||
// if err := netHttp.ListenAndServe(":6060", nil); err != nil && err != netHttp.ErrServerClosed {
|
||||
@@ -65,7 +63,7 @@ func MainApp(configPath string) {
|
||||
|
||||
addr := fmt.Sprintf("%s:%s", config.GetHost(), config.GetPort())
|
||||
zurglog.Infof("Starting server on %s", addr)
|
||||
if err := netHttp.ListenAndServe(addr, handler); err != nil && err != netHttp.ErrServerClosed {
|
||||
if err := netHttp.ListenAndServe(addr, router); err != nil && err != netHttp.ErrServerClosed {
|
||||
zurglog.Errorf("Failed to start server: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user