From 1cd08ba77e97014085e7f92f9ba589039b441b5a Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 24 Apr 2021 00:21:59 +0200 Subject: Exported models to another file --- derelict.go | 7 +------ models.go | 11 +++++++++++ 2 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 models.go diff --git a/derelict.go b/derelict.go index d70598e..ef0b6c3 100644 --- a/derelict.go +++ b/derelict.go @@ -74,12 +74,7 @@ func handleBattlesPost(w http.ResponseWriter, r *http.Request) { http.Error(w, "Unexpected error 1", http.StatusInternalServerError) return } - type wreck struct { - Team int `json:"team"` - Id string `json:"id"` - Hash string `json:"hash"` - } - var wrecks []wreck + var wrecks []Wreck data, err := ioutil.ReadAll(r.Body) if err != nil { http.Error(w, "Unexpected error 2", http.StatusInternalServerError) diff --git a/models.go b/models.go new file mode 100644 index 0000000..d230525 --- /dev/null +++ b/models.go @@ -0,0 +1,11 @@ +package main + +type Killmail struct { + Id string `json:"id"` + Hash string `json:"hash"` +} + +type Wreck struct { + Killmail + Team string `json:"team"` +} -- cgit v1.1