jsonresp

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2016 License: MIT Imports: 2 Imported by: 9

README

json-response

JSON wants returned values to be in key-value format. This package removes a couple lines of code I got tired of copypasta-ing between projects.

Installation

go get github.com/jessemillar/jsonresp

Example Usage

import "github.com/jessemillar/jsonresp"
func SampleFunction(writer http.ResponseWriter, request *http.Request) {
	err := functionThatReturnsAnError()
	if err != nil {
		jsonresp.New(writer, http.StatusBadRequest, "Could not read request body: "+err.Error())
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(writer http.ResponseWriter, httpStatus int, message string)

New returns an error message in proper JSON format

Types

This section is empty.

Jump to

Keyboard shortcuts

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