response

package
v2.0.8 Latest Latest
Warning

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

Go to latest
Published: May 4, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MIMEJSON              = "application/json"
	MIMEHTML              = "text/html"
	MIMEXML               = "application/xml"
	MIMEXML2              = "text/xml"
	MIMEPlain             = "text/plain"
	MIMEPOSTForm          = "application/x-www-form-urlencoded"
	MIMEMultipartPOSTForm = "multipart/form-data"
	MIMEYAML              = "application/x-yaml"
)

Content-Type MIME of the most common data formats.

Variables

This section is empty.

Functions

This section is empty.

Types

type Download

type Download struct {
	// contains filtered or unexported fields
}

func NewDownload

func NewDownload(name string, reader io.Reader) *Download

NewDownload creates file attachment Response with following headers:

Content-Type
Content-Length
Content-Disposition

Content-Type is set using mime#TypeByExtension with the filename's extension. Content-Type will default to application/octet-stream if using a filename with an unknown extension.

func (*Download) Handle

func (rd *Download) Handle(w http.ResponseWriter, r *http.Request) error

func (Download) Status

func (Download) Status() int

type Error

type Error struct {
	// contains filtered or unexported fields
}

func NewError

func NewError(code int, err error) *Error

func (*Error) Handle

func (re *Error) Handle(w http.ResponseWriter, r *http.Request) error

func (*Error) Status

func (re *Error) Status() int

type File

type File struct {
	// contains filtered or unexported fields
}

func NewFile

func NewFile(filepath string) *File

func (*File) Handle

func (rf *File) Handle(w http.ResponseWriter, r *http.Request) error

func (File) Status

func (File) Status() int

type Headers

type Headers struct {
	// contains filtered or unexported fields
}

func NewHeaders

func NewHeaders(code int, headers map[string]string) *Headers

func (*Headers) Handle

func (rh *Headers) Handle(w http.ResponseWriter, r *http.Request) error

func (*Headers) Status

func (rh *Headers) Status() int

type Redirect

type Redirect struct {
	// contains filtered or unexported fields
}

func NewRedirect

func NewRedirect(code int, url string) *Redirect

NewRedirect creates new Response Rediredt object

func (*Redirect) Handle

func (rr *Redirect) Handle(w http.ResponseWriter, r *http.Request) error

func (*Redirect) Status

func (re *Redirect) Status() int

type Render

type Render struct {
	render.Renderer
	// contains filtered or unexported fields
}

func NewData

func NewData(code int, data []byte, contentType []string) *Render

NeweData creates []byte Response

func NewJSON

func NewJSON(code int, data interface{}) *Render

ResponseJSON creates JSON Response

func NewReader

func NewReader(code int, reader io.Reader, contentType []string) *Render

NewReader creates io.Reader render Response for given http code, reader and content type

func NewText

func NewText(code int, text string) *Render

NewText creates Text Response

func NewXML

func NewXML(code int, data interface{}) *Render

NewXML creates XML Response

func (*Render) Handle

func (rr *Render) Handle(w http.ResponseWriter, r *http.Request) error

func (*Render) Status

func (re *Render) Status() int

Jump to

Keyboard shortcuts

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