mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
feat: delete all releases from settings (#170)
This commit is contained in:
parent
c28c6186d9
commit
3b43ccba8a
8 changed files with 148 additions and 14 deletions
|
@ -21,6 +21,14 @@ func (e encoder) StatusResponse(ctx context.Context, w http.ResponseWriter, resp
|
|||
}
|
||||
}
|
||||
|
||||
func (e encoder) StatusNoContent(w http.ResponseWriter) {
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}
|
||||
|
||||
func (e encoder) StatusNotFound(ctx context.Context, w http.ResponseWriter) {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
}
|
||||
|
||||
func (e encoder) StatusInternalError(w http.ResponseWriter) {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ type releaseService interface {
|
|||
Find(ctx context.Context, query domain.ReleaseQueryParams) (res []domain.Release, nextCursor int64, count int64, err error)
|
||||
GetIndexerOptions(ctx context.Context) ([]string, error)
|
||||
Stats(ctx context.Context) (*domain.ReleaseStats, error)
|
||||
Delete(ctx context.Context) error
|
||||
}
|
||||
|
||||
type releaseHandler struct {
|
||||
|
@ -32,6 +33,7 @@ func (h releaseHandler) Routes(r chi.Router) {
|
|||
r.Get("/", h.findReleases)
|
||||
r.Get("/stats", h.getStats)
|
||||
r.Get("/indexers", h.getIndexerOptions)
|
||||
r.Delete("/all", h.deleteReleases)
|
||||
}
|
||||
|
||||
func (h releaseHandler) findReleases(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -135,3 +137,13 @@ func (h releaseHandler) getStats(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
h.encoder.StatusResponse(r.Context(), w, stats, http.StatusOK)
|
||||
}
|
||||
|
||||
func (h releaseHandler) deleteReleases(w http.ResponseWriter, r *http.Request) {
|
||||
err := h.service.Delete(r.Context())
|
||||
if err != nil {
|
||||
h.encoder.StatusInternalError(w)
|
||||
return
|
||||
}
|
||||
|
||||
h.encoder.StatusNoContent(w)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue