-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdoc.go
More file actions
33 lines (33 loc) · 947 Bytes
/
doc.go
File metadata and controls
33 lines (33 loc) · 947 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
// Package respond provides a simple and consistent way of writing
// data API responses when building web services.
//
// // write some data
// respond.With{Data:obj}.To(w,r)
//
// // with specific status
// respond.With{
// Data: obj,
// Status: http.StatusCreated,
// }.To(w,r)
//
// // adding a default header
// respond.DefaultOptions.Headers.Set("X-App-Version", "1.0")
//
// // adding a specific header
// respond.With{
// Data: obj,
// Status: http.StatusCreated,
// Headers: map[string][]string{"X-RateLimit-Remaining": []string{remaining}},
// }.To(w,r)
//
// // your own options for specific responses
// opts := respond.DefaultOptions.Copy()
// opts.WriteData = func(c *respond.Ctx, data interface{}) error {
// /* custom write code */
// }
// respond.With{
// Data: obj,
// Options: opts,
// }.To(w, r)
//
package respond