blob: 9ed7ec3a3ac292badbc847b15c443ce23a6e6e3b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package admin
import (
"net/http"
)
func (s *AdminServer) handleTools(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 tools []string
for _, def := range items {
if def.Tool != nil && def.Tool.Type != "" {
if !seen[def.Tool.Type] {
seen[def.Tool.Type] = true
tools = append(tools, def.Tool.Type)
}
}
}
writeJSON(w, tools)
}
|