-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinterfaces.go
38 lines (30 loc) · 1.06 KB
/
interfaces.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
package response
import (
"context"
"net/http"
)
type FormatWriter interface {
Write(w http.ResponseWriter, statusCode int, data any) error
}
type FactoryWithFormatWriter interface {
FactoryAPI
FormatWriter() FormatWriter
}
type Factory interface {
Response(ctx context.Context, statusCode int, data any) *DataResponse
InternalServerErrorResponse(ctx context.Context, err error) *DataResponse
}
type FactoryAPI interface {
Response(ctx context.Context, statusCode int, data any) *DataResponse
SuccessResponse(ctx context.Context, data any) *DataResponse
InternalServerErrorResponse(ctx context.Context, err error) *DataResponse
UnprocessableEntityResponse(ctx context.Context, message string, attributesErrors map[string][]string) *DataResponse
NotFoundEntityResponse(ctx context.Context, message string) *DataResponse
ErrorResponse(ctx context.Context, statusCode int, message string) *DataResponse
}
type Handler interface {
Handle(f Factory, r *http.Request) *DataResponse
}
type HandlerAPI interface {
Handle(f FactoryAPI, r *http.Request) *DataResponse
}