DELETE /v1/feeds/abc updates all fields to ""
parent
727b4fdea6
commit
cbd4e32022
|
|
@ -10,6 +10,13 @@ import (
|
|||
|
||||
func (h Handler) feeds(w http.ResponseWriter, r *http.Request) error {
|
||||
switch r.Method {
|
||||
case http.MethodDelete:
|
||||
if err := r.ParseForm(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := h.feedsDelete(r.Context(), r.URL.Query().Get("id")); err != nil {
|
||||
return err
|
||||
}
|
||||
case http.MethodPost, http.MethodPut:
|
||||
if err := r.ParseForm(); err != nil {
|
||||
return err
|
||||
|
|
@ -29,6 +36,10 @@ func (h Handler) feeds(w http.ResponseWriter, r *http.Request) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (h Handler) feedsDelete(ctx context.Context, id string) error {
|
||||
return feeds.Delete(ctx, id)
|
||||
}
|
||||
|
||||
func (h Handler) feedsUpsert(ctx context.Context, id string, form url.Values) error {
|
||||
var req feeds.Version
|
||||
for k, v := range map[string]*string{
|
||||
|
|
|
|||
|
|
@ -84,6 +84,10 @@ func ForEach(ctx context.Context, cb func(Feed) error) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func Delete(ctx context.Context, id string) error {
|
||||
return Update(ctx, id, "", "", "", "", "", "")
|
||||
}
|
||||
|
||||
func Get(ctx context.Context, id string) (Feed, error) {
|
||||
if err := initDB(ctx); err != nil {
|
||||
return Feed{}, err
|
||||
|
|
|
|||
Loading…
Reference in New Issue