-
Notifications
You must be signed in to change notification settings - Fork 69
/
response.go
45 lines (39 loc) · 1002 Bytes
/
response.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
43
44
45
package http
import (
"bytes"
"net/http"
)
type Json map[string]any
//go:generate mockery --name=Response
type Response interface {
Data(code int, contentType string, data []byte)
Download(filepath, filename string)
File(filepath string)
Header(key, value string) Response
Json(code int, obj any)
Origin() ResponseOrigin
Redirect(code int, location string)
String(code int, format string, values ...any)
Success() ResponseSuccess
Status(code int) ResponseStatus
Writer() http.ResponseWriter
}
//go:generate mockery --name=ResponseStatus
type ResponseStatus interface {
Data(contentType string, data []byte)
Json(obj any)
String(format string, values ...any)
}
//go:generate mockery --name=ResponseSuccess
type ResponseSuccess interface {
Data(contentType string, data []byte)
Json(obj any)
String(format string, values ...any)
}
//go:generate mockery --name=ResponseOrigin
type ResponseOrigin interface {
Body() *bytes.Buffer
Header() http.Header
Size() int
Status() int
}