package Auth import ( "encoding/json" "net/http" "git.tovijaeschke.xyz/tovi/Envelope/Backend/Database" ) type deviceToken struct { Token string `json:"token"` Type string `json:"type"` } func AddDeviceToken(w http.ResponseWriter, r *http.Request) { var ( token deviceToken userToken Database.DeviceToken err error ) err = json.NewDecoder(r.Body).Decode(&token) if err != nil { http.Error(w, "Error", http.StatusInternalServerError) return } userToken = Database.DeviceToken{ Token: token.Token, DeviceType: token.Type, } err = (&userToken).CreateUserDeviceToken() if err != nil { http.Error(w, "Error", http.StatusInternalServerError) return } w.WriteHeader(http.StatusNoContent) }