go-respond: github.com/nicklaw5/go-respond Index | Files

package respond

import "github.com/nicklaw5/go-respond"


Package Files

error.go response.go success.go

type DefaultMessageResponse Uses

type DefaultMessageResponse struct {
    Status  int    `json:"status"`
    Message string `json:"message"`

DefaultMessageResponse is for transporting a default http message

type Response Uses

type Response struct {
    Writer     http.ResponseWriter
    Headers    map[string]string
    DefMessage bool

Response is the HTTP response

func NewResponse Uses

func NewResponse(w http.ResponseWriter) *Response

NewResponse creates and returns a new response

func (*Response) Accepted Uses

func (resp *Response) Accepted(v interface{})

Accepted returns a 202 Accepted JSON response

func (*Response) AddHeader Uses

func (resp *Response) AddHeader(key string, value string) *Response

AddHeader adds a single header to the response

func (*Response) BadGateway Uses

func (resp *Response) BadGateway(v interface{})

BadGateway returns a 502 Bad Gateway JSON response

func (*Response) BadRequest Uses

func (resp *Response) BadRequest(v interface{})

BadRequest returns a 400 Bad Request JSON response

func (*Response) Conflict Uses

func (resp *Response) Conflict(v interface{})

Conflict returns a 409 Conflict JSON response

func (*Response) Created Uses

func (resp *Response) Created(v interface{})

Created returns a 201 Created JSON response

func (*Response) DefaultMessage Uses

func (resp *Response) DefaultMessage() *Response

func (*Response) DeleteHeader Uses

func (resp *Response) DeleteHeader(key string) *Response

DeleteHeader deletes a single header from the response

func (*Response) Forbidden Uses

func (resp *Response) Forbidden(v interface{})

Forbidden returns a 401 Forbidden JSON response

func (*Response) GatewayTimeout Uses

func (resp *Response) GatewayTimeout(v interface{})

GatewayTimeout returns a 504 Gateway Timeout JSON response

func (*Response) InternalServerError Uses

func (resp *Response) InternalServerError(v interface{})

InternalServerError returns a 500 Internal Server Error JSON response

func (*Response) LengthRequired Uses

func (resp *Response) LengthRequired(v interface{})

LengthRequired returns a 411 Length Required JSON response

func (*Response) MethodNotAllowed Uses

func (resp *Response) MethodNotAllowed(v interface{})

MethodNotAllowed returns a 405 Method Not Allowed JSON response

func (*Response) NoContent Uses

func (resp *Response) NoContent()

NoContent returns a 204 No Content JSON response

func (*Response) NotFound Uses

func (resp *Response) NotFound(v interface{})

NotFound returns a 404 Not Found JSON response

func (*Response) NotImplemented Uses

func (resp *Response) NotImplemented(v interface{})

NotImplemented returns a 501 Not Implemented JSON response

func (*Response) Ok Uses

func (resp *Response) Ok(v interface{})

Ok returns a 200 OK JSON response

func (*Response) PreconditionFailed Uses

func (resp *Response) PreconditionFailed(v interface{})

PreconditionFailed returns a 412 Precondition Failed JSON response

func (*Response) RequestEntityTooLarge Uses

func (resp *Response) RequestEntityTooLarge(v interface{})

RequestEntityTooLarge returns a 413 Request Entity Too Large JSON response

func (*Response) ServiceUnavailable Uses

func (resp *Response) ServiceUnavailable(v interface{})

ServiceUnavailable returns a 503 Service Unavailable JSON response

func (*Response) Unauthorized Uses

func (resp *Response) Unauthorized(v interface{})

Unauthorized returns a 401 Unauthorized JSON response

func (*Response) UnprocessableEntity Uses

func (resp *Response) UnprocessableEntity(v interface{})

UnprocessableEntity returns a 422 Unprocessable Entity JSON response

func (*Response) UnsupportedMediaType Uses

func (resp *Response) UnsupportedMediaType(v interface{})

UnsupportedMediaType returns a 415 Unsupported Media Type JSON response

Package respond imports 2 packages (graph). Updated 2019-07-23. Refresh now. Tools for package owners.