errorJson

package
v1.0.0-...-4f7f1ef Latest Latest
Warning

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

Go to latest
Published: May 31, 2016 License: LGPL-3.0 Imports: 5 Imported by: 0

README

martini enhanced return handler

Usage

package main

import (
	"fmt"

	"github.com/go-martini/martini"
	"github.com/martini-contrib/render"
	"github.com/tsaikd/KDGoLib/martini/errorJson"
)

func main() {
	m := martini.Classic()
	m.Map(errorJson.ReturnErrorProvider())
	m.Use(render.Renderer())
	m.Get("/", func() err {
		return fmt.Errorf("error")
	})
	m.Run()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindMartini

func BindMartini(m *martini.Martini)

BindMartini bind return error handler to martini instance

func RenderErrorJSON

func RenderErrorJSON(render render.Render, status int, err error, errs ...error)

RenderErrorJSON render error in json format

Types

type ReturnError

type ReturnError struct {
	Status int
	Body   []byte
	Error  error
}

ReturnError define api function call return error struct

func (*ReturnError) AddError

func (t *ReturnError) AddError(err error)

AddError add error to ReturnError

Jump to

Keyboard shortcuts

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