herodot

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const RequestIDKey key = 0

Variables

This section is empty.

Functions

func Context

func Context(ctx context.Context) context.Context

func LogError added in v0.5.0

func LogError(err error, id string, code int)

func NewContext

func NewContext() context.Context

Types

type Error

type Error struct {
	OriginalError error  `json:"-"`
	StatusCode    int    `json:"code"`
	Description   string `json:"description,omitempty"`
	Name          string `json:"name"`
}

func ToError

func ToError(err error) *Error

func (Error) Error

func (e Error) Error() string

type Herodot

type Herodot interface {
	Write(ctx context.Context, w http.ResponseWriter, r *http.Request, e interface{})

	WriteCode(ctx context.Context, w http.ResponseWriter, r *http.Request, code int, e interface{})

	WriteCreated(ctx context.Context, w http.ResponseWriter, r *http.Request, location string, e interface{})

	WriteError(ctx context.Context, w http.ResponseWriter, r *http.Request, err error)

	WriteErrorCode(ctx context.Context, w http.ResponseWriter, r *http.Request, code int, err error)
}

type JSON

type JSON struct {
	Logger logrus.FieldLogger
}

func (*JSON) Write

func (h *JSON) Write(ctx context.Context, w http.ResponseWriter, r *http.Request, e interface{})

func (*JSON) WriteCode

func (h *JSON) WriteCode(ctx context.Context, w http.ResponseWriter, r *http.Request, code int, e interface{})

func (*JSON) WriteCreated

func (h *JSON) WriteCreated(ctx context.Context, w http.ResponseWriter, r *http.Request, location string, e interface{})

func (*JSON) WriteError

func (h *JSON) WriteError(ctx context.Context, w http.ResponseWriter, r *http.Request, err error)

func (*JSON) WriteErrorCode

func (h *JSON) WriteErrorCode(ctx context.Context, w http.ResponseWriter, r *http.Request, code int, err error)

Jump to

Keyboard shortcuts

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