// POST /files/delete func FileDelete(w rest.ResponseWriter, r *rest.Request) { r.ParseForm() id, _ := strconv.ParseInt(r.FormValue("Id"), 10, 64) file := database.FindFile(id) // Delete from DB database.DeleteFile(file) w.WriteJson("") }
// POST /releases/delete func ReleaseDelete(w rest.ResponseWriter, r *rest.Request) { r.ParseForm() id, _ := strconv.ParseInt(r.FormValue("Id"), 10, 64) release := database.FindRelease(id) file := database.FindFile(release.FileId) // Delete from DB database.DeleteRelease(release) database.UnpublishFile(file) go database.RefreshBuilds() // http.Redirect(w, r, "/admin/releases", http.StatusFound) w.WriteJson("") }
// POST /releases/update func ReleaseUpdate(w rest.ResponseWriter, r *rest.Request) { r.ParseForm() // Parse form and append to struct id, _ := strconv.ParseInt(r.FormValue("Id"), 10, 64) fileId, _ := strconv.ParseInt(r.FormValue("FileId"), 10, 64) release := database.FindRelease(id) file := database.FindFile(fileId) release.FileId = file.Id release.FileName = file.Name release.Channel = r.FormValue("Channel") release.Changelog = r.FormValue("Changelog") // Append to db database.UpdateRelease(release) // Redirect w.WriteJson("") }
// POST /releases/create func ReleaseCreate(w rest.ResponseWriter, r *rest.Request) { r.ParseForm() fileId, _ := strconv.ParseInt(r.FormValue("FileId"), 10, 64) file := database.FindFile(fileId) // Generate release release := database.Release{ Created: time.Now().UnixNano(), Changelog: r.FormValue("Changelog"), Channel: r.FormValue("Channel"), FileId: file.Id, FileName: file.Name, } database.CreateRelease(release) database.PublishFile(file) go database.RefreshBuilds() w.WriteJson("") }
// GET /files/show/:id func File(w rest.ResponseWriter, r *rest.Request) { id, _ := strconv.ParseInt(r.PathParam("id"), 10, 64) file := fileResource(database.FindFile(id)) w.WriteJson(apiResponse(r, file)) }