inertia: github.com/ubclaunchpad/inertia/daemon/inertiad/res Index | Files

package res

import "github.com/ubclaunchpad/inertia/daemon/inertiad/res"

Package res provides simple HTTP response primitives

Index

Package Files

base.go doc.go error.go message.go

type BaseResponse Uses

type BaseResponse struct {
    api.BaseResponse
}

BaseResponse is a container class around api.BaseResponse

func (*BaseResponse) Render Uses

func (b *BaseResponse) Render(w http.ResponseWriter, r *http.Request) error

Render implements chi's render.Renderer

type ErrResponse Uses

type ErrResponse struct {
    *BaseResponse
}

ErrResponse is the template for a typical HTTP response for errors

func Err Uses

func Err(message string, code int, kvs ...interface{}) *ErrResponse

Err is a basic error response constructor

func ErrBadRequest Uses

func ErrBadRequest(message string, kvs ...interface{}) *ErrResponse

ErrBadRequest is a shortcut for bad requests

func ErrForbidden Uses

func ErrForbidden(message string, kvs ...interface{}) *ErrResponse

ErrForbidden is a shortcut for forbidden requests

func ErrInternalServer Uses

func ErrInternalServer(message string, err error, kvs ...interface{}) *ErrResponse

ErrInternalServer is a shortcut for internal server errors. It should be accompanied by an actual error.

func ErrNotFound Uses

func ErrNotFound(message string, kvs ...interface{}) *ErrResponse

ErrNotFound is a shortcut for forbidden requests

func ErrUnauthorized Uses

func ErrUnauthorized(message string, kvs ...interface{}) *ErrResponse

ErrUnauthorized is a shortcut for unauthorized requests

type MsgResponse Uses

type MsgResponse struct {
    *BaseResponse
}

MsgResponse is the template for a typical HTTP response for messages

func Msg Uses

func Msg(message string, code int, kvs ...interface{}) *MsgResponse

Msg is a shortcut for non-error statuses

func MsgOK Uses

func MsgOK(message string, kvs ...interface{}) *MsgResponse

MsgOK is a shortcut for an ok-status response

Package res imports 4 packages (graph) and is imported by 3 packages. Updated 2019-02-26. Refresh now. Tools for package owners.