-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.snap.txt
More file actions
115 lines (71 loc) · 2.76 KB
/
api.snap.txt
File metadata and controls
115 lines (71 loc) · 2.76 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package rsvp // import "github.com/Teajey/rsvp"
CONSTANTS
const (
SupportedMediaTypePlaintext string = "text/plain"
SupportedMediaTypeHtml string = "text/html"
SupportedMediaTypeCsv string = "text/csv"
SupportedMediaTypeBytes string = "application/octet-stream"
SupportedMediaTypeJson string = "application/json"
SupportedMediaTypeXml string = "application/xml"
SupportedMediaTypeGob string = "application/vnd.golang.gob"
)
VARIABLES
var ErrFailedToMatchHtmlTemplate = errors.New("TemplateName was set, but it failed to match within HtmlTemplate")
var ErrFailedToMatchTextTemplate = errors.New("TemplateName was set, but it failed to match within TextTemplate")
FUNCTIONS
func AdaptHandler(config Config, next Handler) http.Handler
func AdaptHandlerFunc(cfg Config, next HandlerFunc) http.HandlerFunc
func Write(w io.Writer, cfg Config, wh http.Header, r *http.Request, handler HandlerFunc) (int, error)
func WriteHandler(cfg Config, rw http.ResponseWriter, r *http.Request, handler HandlerFunc) error
func WriteResponse(status int, w http.ResponseWriter, r io.Reader) error
TYPES
type Body struct {
Data any
TemplateName string
// Has unexported fields.
}
func Blank() Body
func Data(data any) Body
func (res *Body) MediaTypes(cfg Config) iter.Seq[string]
func (r Body) StatusAccepted() Body
func (r Body) StatusBadRequest() Body
func (r Body) StatusConflict() Body
func (r Body) StatusCreated(location string) Body
func (r Body) StatusForbidden() Body
func (r Body) StatusFound(location string) Body
func (r Body) StatusGone() Body
func (r Body) StatusInternalServerError() Body
func (r Body) StatusMethodNotAllowed() Body
func (r Body) StatusMovedPermanently(location string) Body
func (r Body) StatusNoContent() Body
func (r Body) StatusNotAcceptable() Body
func (r Body) StatusNotFound() Body
func (r Body) StatusNotImplemented() Body
func (r Body) StatusNotModified() Body
func (r Body) StatusPermanentRedirect(location string) Body
func (r Body) StatusSeeOther(location string) Body
func (r Body) StatusServiceUnavailable() Body
func (r Body) StatusTemporaryRedirect(location string) Body
func (r Body) StatusTooManyRequests() Body
func (r Body) StatusUnauthorized() Body
func (r Body) StatusUnprocessableEntity() Body
type Config struct {
HtmlTemplate *html.Template
TextTemplate *text.Template
JsonPrefix string
JsonIndent string
XmlPrefix string
XmlIndent string
}
type Csv interface {
MarshalCsv(w *csv.Writer) error
}
type Handler interface {
ServeHTTP(w ResponseWriter, r *http.Request) Body
}
type HandlerFunc func(w ResponseWriter, r *http.Request) Body
func (f HandlerFunc) ServeHTTP(w ResponseWriter, r *http.Request) Body
type ResponseWriter interface {
Header() http.Header
DefaultTemplateName(name string)
}