Integrate GoAdmin into main API with auto-migrations
- Admin panel accessible at /admin on the same domain - GoAdmin tables created automatically during startup migrations - Default credentials: admin / admin 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -9,9 +9,11 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
_ "github.com/lib/pq" // PostgreSQL driver for GoAdmin
|
||||
"github.com/rs/zerolog/log"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/treytartt/mycrib-api/internal/admin"
|
||||
"github.com/treytartt/mycrib-api/internal/config"
|
||||
"github.com/treytartt/mycrib-api/internal/database"
|
||||
"github.com/treytartt/mycrib-api/internal/router"
|
||||
@@ -91,6 +93,15 @@ func main() {
|
||||
}
|
||||
r := router.SetupRouter(deps)
|
||||
|
||||
// Setup GoAdmin panel at /admin
|
||||
if db != nil {
|
||||
if _, err := admin.Setup(r, cfg); err != nil {
|
||||
log.Warn().Err(err).Msg("Failed to setup admin panel - admin will be unavailable")
|
||||
} else {
|
||||
log.Info().Msg("Admin panel available at /admin")
|
||||
}
|
||||
}
|
||||
|
||||
// Create HTTP server
|
||||
srv := &http.Server{
|
||||
Addr: fmt.Sprintf(":%d", cfg.Server.Port),
|
||||
|
||||
Reference in New Issue
Block a user