type Item struct { Name string `json:"name"` Author string `json:"author"` SecretKey string `json:"secretKey"` Model uint16 `json:"model"` Bone uint8 `json:"bone"` Position [3]float64 `json:"position"` Rotation [3]float64 `json:"rotation"` Scale [3]float64 `json:"scale"` }
var items []Item
func listRequestHandler(w http.ResponseWriter, r *http.Request) { if r.Method != "GET" { w.WriteHeader(http.StatusMethodNotAllowed) return } jsonString, err := json.Marshal(items) if err != nil { w.WriteHeader(http.StatusInternalServerError) w.Write([]byte(err.Error())) return } w.WriteHeader(http.StatusOK) w.Write([]byte(string(jsonString))) }
userItems := make([]Item, len(items)) copy(userItems, items) for index := range userItems { userItems[index].SecretKey = "*" } jsonString, err := json.Marshal(userItems)