response

package
v0.0.0-...-45d6836 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Response

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

Response is used to facilitate writing http responses

func CreateResponse

func CreateResponse(writer http.ResponseWriter, logger debug.Logger) *Response

CreateResponse returns a new response object

func (*Response) BadRequest

func (r *Response) BadRequest(err string)

BadRequest Writes a status badrequest and a err message

func (*Response) Created

func (r *Response) Created(data []byte)

Created returns http created status code and write the newly created object

func (*Response) ServerError

func (r *Response) ServerError(err string)

ServerError returns internalServerError status code and log the error

func (*Response) WriteError

func (r *Response) WriteError(status int, err string)

WriteError writes a generic error to the reponse

func (*Response) WriteHeader

func (r *Response) WriteHeader(headerKey string, value string)

WriteHeader write a header to a response(prefer not using this directly)- call this before WriteJSON

func (*Response) WriteJSON

func (r *Response) WriteJSON(data []byte)

WriteJSON write json to the response and set header type to json- status code is 200ok

func (*Response) WriteJSONWithStatusCode

func (r *Response) WriteJSONWithStatusCode(data []byte, status int)

WriteJSONWithStatusCode write a json and a status code to the response

Jump to

Keyboard shortcuts

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