response

package
v0.0.0-...-900be4e Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 5 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 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 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 (*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(key, value string) *NormalResponse

func (*NormalResponse) Status

func (r *NormalResponse) Status() int

Status gets the response's status.

func (*NormalResponse) WriteTo

func (r *NormalResponse) WriteTo(ctx *models.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 *models.ReqContext)

WriteTo writes to a response.

type Response

type Response interface {
	// WriteTo writes to a context.
	WriteTo(ctx *models.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 *models.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