aboutsummaryrefslogtreecommitdiff
path: root/internal/admin/server.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/admin/server.go')
-rw-r--r--internal/admin/server.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/internal/admin/server.go b/internal/admin/server.go
index 9983a0b..842f640 100644
--- a/internal/admin/server.go
+++ b/internal/admin/server.go
@@ -55,9 +55,12 @@ type AdminServer struct {
// admin web GUI can trigger the same migration as the swapid command
// without the admin package depending on game.
rewriteRoomIDs func(idMap map[int]int)
+ // configPath is the on-disk config.yaml path, used by the color themer
+ // to persist edited default_colors back to the file the game loaded.
+ configPath string
}
-func NewServer(cfg *config.Config, useTLS bool, accountStore *player.AccountStore, w *world.World, is *item.ItemStore, os *object.ObjectStore, ms *world.MobStore, dataDir string, reloadCourses func(), rewriteRoomIDs func(map[int]int)) (*AdminServer, error) {
+func NewServer(cfg *config.Config, useTLS bool, accountStore *player.AccountStore, w *world.World, is *item.ItemStore, os *object.ObjectStore, ms *world.MobStore, dataDir string, reloadCourses func(), rewriteRoomIDs func(map[int]int), configPath string) (*AdminServer, error) {
secret := make([]byte, 32)
if _, err := rand.Read(secret); err != nil {
return nil, fmt.Errorf("cookie secret: %w", err)
@@ -102,6 +105,7 @@ func NewServer(cfg *config.Config, useTLS bool, accountStore *player.AccountStor
cookieSecret: secret,
reloadCourses: reloadCourses,
rewriteRoomIDs: rewriteRoomIDs,
+ configPath: configPath,
}
mux := http.NewServeMux()
@@ -185,6 +189,8 @@ func NewServer(cfg *config.Config, useTLS bool, accountStore *player.AccountStor
apiMux.HandleFunc("/api/rooms/resolve-duplicate", s.handleResolveDuplicate)
apiMux.HandleFunc("/api/triggers", s.handleTriggers)
apiMux.HandleFunc("/api/triggers/", s.handleTriggerByID)
+ apiMux.HandleFunc("/api/colors", s.handleColors)
+ apiMux.HandleFunc("/api/colors/reset", s.handleColorsReset)
mux.Handle("/api/", s.authMiddleware(apiMux))