-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete_blog_posts.go
More file actions
43 lines (37 loc) · 910 Bytes
/
delete_blog_posts.go
File metadata and controls
43 lines (37 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package http
import (
"net/http"
"strconv"
"github.com/gorilla/mux"
"github.com/hammer-code/lms-be/domain"
"github.com/hammer-code/lms-be/utils"
"github.com/sirupsen/logrus"
)
// DeleteBlogPost implements domain.BlogPostHandler.
func (h Handler) DeleteBlogPost(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
idString := vars["id"]
value, err := strconv.ParseUint(idString, 10, 32)
if err != nil {
logrus.Error("failed to convert string to uint: ", err)
utils.Response(domain.HttpResponse{
Code: 500,
Message: err.Error(),
}, w)
return
}
err = h.usecase.DeleteBlogPost(r.Context(), uint(value))
if err != nil {
logrus.Error("failed to delete event : ", err)
utils.Response(domain.HttpResponse{
Code: 500,
Message: err.Error(),
}, w)
return
}
utils.Response(domain.HttpResponse{
Code: 200,
Message: "success",
Data: nil,
}, w)
}