write

package
v0.24.2 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2021 License: MIT Imports: 2 Imported by: 0

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