Adekabang 8eaee0be8c refactor: update project references from Adekabang to khairul169
- Change Docker image references in docker-compose.yml and documentation
- Update Go module path and import statements in backend code
- Modify build script to reflect new image name
- Remove outdated copyright information from LICENSE file
2025-09-29 20:26:44 -04:00

50 lines
1.0 KiB
Go

package main
import (
"fmt"
"khairul169/garage-webui/router"
"khairul169/garage-webui/ui"
"khairul169/garage-webui/utils"
"log"
"net/http"
"os"
"github.com/joho/godotenv"
)
func main() {
// Initialize app
godotenv.Load()
utils.InitCacheManager()
sessionMgr := utils.InitSessionManager()
if err := utils.Garage.LoadConfig(); err != nil {
log.Println("Cannot load garage config!", err)
}
basePath := os.Getenv("BASE_PATH")
mux := http.NewServeMux()
// Serve API
apiPrefix := basePath + "/api"
mux.Handle(apiPrefix+"/", http.StripPrefix(apiPrefix, router.HandleApiRouter()))
// Static files
ui.ServeUI(mux)
// Redirect to UI if BASE_PATH is set
if basePath != "" {
mux.Handle("/", http.RedirectHandler(basePath, http.StatusMovedPermanently))
}
host := utils.GetEnv("HOST", "0.0.0.0")
port := utils.GetEnv("PORT", "3909")
addr := fmt.Sprintf("%s:%s", host, port)
log.Printf("Starting server on http://%s", addr)
if err := http.ListenAndServe(addr, sessionMgr.LoadAndSave(mux)); err != nil {
log.Fatal(err)
}
}