aboutsummaryrefslogtreecommitdiff
path: root/internal/admin/api_stations.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/admin/api_stations.go')
-rw-r--r--internal/admin/api_stations.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/internal/admin/api_stations.go b/internal/admin/api_stations.go
new file mode 100644
index 0000000..411ed96
--- /dev/null
+++ b/internal/admin/api_stations.go
@@ -0,0 +1,37 @@
+package admin
+
+import (
+ "net/http"
+)
+
+func (s *AdminServer) handleStations(w http.ResponseWriter, r *http.Request) {
+ if r.Method != http.MethodGet {
+ http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
+ return
+ }
+
+ items, err := s.itemStore.LoadAll()
+ if err != nil {
+ http.Error(w, "failed to load items", http.StatusInternalServerError)
+ return
+ }
+
+ seen := map[string]bool{}
+ var stations []string
+ for _, def := range items {
+ if def.Craft != nil {
+ for _, c := range def.Craft {
+ for _, s := range c.Station {
+ if s != "" {
+ if !seen[s] {
+ seen[s] = true
+ stations = append(stations, s)
+ }
+ }
+ }
+ }
+ }
+ }
+
+ writeJSON(w, stations)
+}