Documentation
¶
Index ¶
- func ReadResponse(r io.Reader, v interface{}) error
- func WriteError(w http.ResponseWriter, error string, code int) error
- func WriteResponse(w http.ResponseWriter, data interface{}, code int) error
- func WriteResponsePage(w http.ResponseWriter, data interface{}, pd *PageDetails, code int) error
- type Error
- type PageDetails
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadResponse ¶
ReadResponse reads a JSON response, and unmarshals the supplied data.
func WriteError ¶
func WriteError(w http.ResponseWriter, error string, code int) error
WriteError encodes the supplied error in a response, and writes to w.
func WriteResponse ¶
func WriteResponse(w http.ResponseWriter, data interface{}, code int) error
WriteResponse encodes the supplied data in a response, and writes to w.
func WriteResponsePage ¶ added in v0.2.0
func WriteResponsePage(w http.ResponseWriter, data interface{}, pd *PageDetails, code int) error
WriteResponsePage encodes the supplied data in a paged JSON response, and writes to w.
Types ¶
type Error ¶
Error describes an error condition.
type PageDetails ¶ added in v0.2.0
type PageDetails struct {
Prev string `json:"prev,omitempty"`
Next string `json:"next,omitempty"`
TotalSize int `json:"totalSize,omitempty"`
}
PageDetails specifies paging information.
func ReadResponsePage ¶ added in v0.2.0
func ReadResponsePage(r io.Reader, v interface{}) (pd *PageDetails, err error)
ReadResponsePage reads a paged JSON response, and unmarshals the supplied data.
type Response ¶
type Response struct {
Data interface{} `json:"data,omitempty"`
Page *PageDetails `json:"page,omitempty"`
Error *Error `json:"error,omitempty"`
}
Response is the top level container of all of our REST API responses.
Click to show internal directories.
Click to hide internal directories.
