responses

package
v0.0.0-...-76439fa Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2019 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STATUS_INVALID           = 400
	STATUS_PERMISSION_DENIED = 401
	STATUS_NOTFOUND          = 404
	STATUS_INERNAL_ERROR     = 500

	MESSAGE_ACCESS_DENIED  = "access denied"
	MESSAGE_NOT_FOUND      = "not found"
	MESSAGE_UNAUTHORIZED   = "unauthorized"
	MESSAGE_INTERNAL_ERROR = "internal server error"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorResponse

type ErrorResponse struct {
	Status  int      `json:"-"`
	Message string   `json:"error"`
	Details []string `json:"details"`
}

func Denied

func Denied() ErrorResponse

Denied creates a 401 Unauthorized response.

func InternalError

func InternalError(message string) ErrorResponse

InternalError creates a 500 Internal Server Error response with an optional message.

func Invalid

func Invalid(message string, details []string) ErrorResponse

Invalid creates an ErrorResponse for an invalid request.

func NotFound

func NotFound() ErrorResponse

NotFound creates a 404 Not Found response.

func Unauthorized

func Unauthorized(message string) ErrorResponse

Unauthorized creates a 401 Unauthorized response with an optional message.

Jump to

Keyboard shortcuts

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