write

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: MIT Imports: 2 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package write provides http-related functions, types, utilities, etc. The package name was deliberately chosen so as to not conflict with net/http, as these two packages are bound to be used together.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeJSON

func EncodeJSON(w http.ResponseWriter, v interface{})

EncodeJSON conveniently writes JSON data responses.

func Error

func Error(w http.ResponseWriter, err string, code int)

Error writes an HTTP JSON error response.

func OK

func OK(w http.ResponseWriter)

OK writes an HTTP JSON ok response.

Types

type ErrorResponse

type ErrorResponse struct {
	Status     int    `json:"status"`
	StatusText string `json:"statusText"`
	Error      string `json:"error"`
}

ErrorResponse provides a standard error response format.

type OKResponse

type OKResponse struct {
	Status     int    `json:"status"`
	StatusText string `json:"statusText"`
}

Jump to

Keyboard shortcuts

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