restserializer

package module
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2021 License: MIT Imports: 5 Imported by: 0

README

RESTSerializer package

RESTSerializer is a golang REST serializer helper. You can create your own entity serializer interface and implement this one.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadRequest = errors.New("error bad request")
View Source
var ErrConflict = errors.New("error conflict")
View Source
var ErrForbidden = errors.New("error access forbidden")
View Source
var ErrNotFound = errors.New("error not found")
View Source
var ErrUnknown = errors.New("error unknown")

Functions

func HttpErrorRender

func HttpErrorRender(err error, w http.ResponseWriter, resource string)

func RenderError

func RenderError(err error, w http.ResponseWriter, statusCode int, resource string)

func WriteContentType

func WriteContentType(w http.ResponseWriter)

Types

type ErrBody

type ErrBody struct {
	Error Error `json:"error"`
}

type Error

type Error struct {
	Resource   string `json:"resource,omitempty"`
	Message    string `json:"message"`
	StatusCode int    `json:"statusCode"`
	Status     string `json:"status"`
}

type ErrorSerializer

type ErrorSerializer interface {
	RenderError(err error, w http.ResponseWriter, statusCode int)
	WriteContentType(w http.ResponseWriter)
}

Jump to

Keyboard shortcuts

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