response

package
v0.0.0-...-fb7f86c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2023 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

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 Empty

func Empty(status int) *NormalResponse

Empty creates an empty 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 JSON

func JSON(status int, body interface{}) *NormalResponse

JSON creates a JSON 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 Success

func Success(message string) *NormalResponse

Success create a successful response

func YAML

func YAML(status int, body interface{}) *NormalResponse

YAML creates a YAML 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) Body

func (r *NormalResponse) Body() []byte

Body gets the response's body.

func (*NormalResponse) Err

func (r *NormalResponse) Err() error

Err gets the response's err.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL