-
Notifications
You must be signed in to change notification settings - Fork 2
/
find_all_transfer.go
42 lines (34 loc) · 1.01 KB
/
find_all_transfer.go
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
package action
import (
"net/http"
"github.com/felixa1996/go-plate/adapter/api/logging"
"github.com/felixa1996/go-plate/adapter/api/response"
"github.com/felixa1996/go-plate/adapter/logger"
"github.com/felixa1996/go-plate/usecase"
)
type FindAllTransferAction struct {
uc usecase.FindAllTransferUseCase
log logger.Logger
}
func NewFindAllTransferAction(uc usecase.FindAllTransferUseCase, log logger.Logger) FindAllTransferAction {
return FindAllTransferAction{
uc: uc,
log: log,
}
}
func (t FindAllTransferAction) Execute(w http.ResponseWriter, r *http.Request) {
const logKey = "find_all_transfer"
output, err := t.uc.Execute(r.Context())
if err != nil {
logging.NewError(
t.log,
err,
logKey,
http.StatusInternalServerError,
).Log("error when returning the transfer list")
response.NewError(err, http.StatusInternalServerError).Send(w)
return
}
logging.NewInfo(t.log, logKey, http.StatusOK).Log("success when returning transfer list")
response.NewSuccess(output, http.StatusOK).Send(w)
}