Documentation ¶
Index ¶
- type NormalResponse
- func CreateNormalResponse(header http.Header, body []byte, status int) *NormalResponse
- func Empty(status int) *NormalResponse
- func Err(err error) *NormalResponse
- func ErrOrFallback(status int, message string, err error) *NormalResponse
- func Error(status int, message string, err error) *NormalResponse
- func JSON(status int, body interface{}) *NormalResponse
- func JSONDownload(status int, body interface{}, filename string) *NormalResponse
- func Respond(status int, body interface{}) *NormalResponse
- func Success(message string) *NormalResponse
- func YAML(status int, body interface{}) *NormalResponse
- func YAMLDownload(status int, body interface{}, filename string) *NormalResponse
- func (r *NormalResponse) Body() []byte
- func (r *NormalResponse) Err() error
- func (r *NormalResponse) ErrMessage() string
- func (r *NormalResponse) Header() http.Header
- func (r *NormalResponse) SetHeader(key, value string) *NormalResponse
- func (r *NormalResponse) Status() int
- func (r *NormalResponse) Write(b []byte) (int, error)
- func (r *NormalResponse) WriteHeader(statusCode int)
- func (r *NormalResponse) WriteTo(ctx *contextmodel.ReqContext)
- type RedirectResponse
- type Response
- type StreamingResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NormalResponse ¶
type NormalResponse struct {
// contains filtered or unexported fields
}
func CreateNormalResponse ¶
func CreateNormalResponse(header http.Header, body []byte, status int) *NormalResponse
func Err ¶
func Err(err error) *NormalResponse
Err creates an error response based on an errutil.Error error.
func ErrOrFallback ¶
func ErrOrFallback(status int, message string, err error) *NormalResponse
ErrOrFallback uses the information in an errutil.Error if available and otherwise falls back to the status and message provided as arguments.
The signature is equivalent to that of Error which allows us to rename this to Error when we're confident that that would be safe to do.
func Error ¶
func Error(status int, message string, err error) *NormalResponse
Error creates an error response.
func JSONDownload ¶
func JSONDownload(status int, body interface{}, filename string) *NormalResponse
JSONDownload creates a JSON response indicating that it should be downloaded.
func Respond ¶
func Respond(status int, body interface{}) *NormalResponse
Respond creates a response.
func YAMLDownload ¶
func YAMLDownload(status int, body interface{}, filename string) *NormalResponse
YAMLDownload creates a YAML response indicating that it should be downloaded.
func (*NormalResponse) ErrMessage ¶
func (r *NormalResponse) ErrMessage() string
ErrMessage gets the response's errMessage.
func (*NormalResponse) Header ¶
func (r *NormalResponse) Header() http.Header
Header implements http.ResponseWriter
func (*NormalResponse) SetHeader ¶
func (r *NormalResponse) SetHeader(key, value string) *NormalResponse
func (*NormalResponse) Status ¶
func (r *NormalResponse) Status() int
Status gets the response's status.
func (*NormalResponse) Write ¶
func (r *NormalResponse) Write(b []byte) (int, error)
Write implements http.ResponseWriter
func (*NormalResponse) WriteHeader ¶
func (r *NormalResponse) WriteHeader(statusCode int)
WriteHeader implements http.ResponseWriter
func (*NormalResponse) WriteTo ¶
func (r *NormalResponse) WriteTo(ctx *contextmodel.ReqContext)
type RedirectResponse ¶
type RedirectResponse struct {
// contains filtered or unexported fields
}
RedirectResponse represents a redirect response.
func Redirect ¶
func Redirect(location string) *RedirectResponse
func (*RedirectResponse) Body ¶
func (r *RedirectResponse) Body() []byte
Body gets the response's body. Required to implement api.Response.
func (*RedirectResponse) Status ¶
func (*RedirectResponse) Status() int
Status gets the response's status. Required to implement api.Response.
func (*RedirectResponse) WriteTo ¶
func (r *RedirectResponse) WriteTo(ctx *contextmodel.ReqContext)
WriteTo writes to a response.
type Response ¶
type Response interface { // WriteTo writes to a context. WriteTo(ctx *contextmodel.ReqContext) // Body gets the response's body. Body() []byte // Status gets the response's status. Status() int }
Response is an HTTP response interface.
type StreamingResponse ¶
type StreamingResponse struct {
// contains filtered or unexported fields
}
StreamingResponse is a response that streams itself back to the client.
func JSONStreaming ¶
func JSONStreaming(status int, body interface{}) StreamingResponse
JSONStreaming creates a streaming JSON response.
func (StreamingResponse) Body ¶
func (r StreamingResponse) Body() []byte
Body gets the response's body. Required to implement api.Response.
func (StreamingResponse) Status ¶
func (r StreamingResponse) Status() int
Status gets the response's status. Required to implement api.Response.
func (StreamingResponse) WriteTo ¶
func (r StreamingResponse) WriteTo(ctx *contextmodel.ReqContext)
WriteTo writes the response to the provided context. Required to implement api.Response.