writer

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: Apache-2.0 Imports: 5 Imported by: 29 modules, 30 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 writer contains utilities for writing responses in the server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes

func Bytes(w http.ResponseWriter, code int, bs []byte)

Bytes writes a response with the specified status code and bytes.

func Error

func Error(w http.ResponseWriter, status int, err *types.ErrorV1)

Error writes a response with specified status and error response.

func ErrorAuto

func ErrorAuto(w http.ResponseWriter, err error)

ErrorAuto writes a response with status and code set automatically based on the type of err.

func ErrorString

func ErrorString(w http.ResponseWriter, status int, code string, err error)

ErrorString writes a response with specified status, code, and message set to the the err's string representation.

func HTTPStatus added in v0.6.0

func HTTPStatus(code int) http.HandlerFunc

HTTPStatus is used to set a specific status code Adapted from https://stackoverflow.com/questions/27711154/what-response-code-to-return-on-a-non-supported-http-method-on-rest

func JSON

func JSON(w http.ResponseWriter, code int, v interface{}, pretty bool)

JSON writes a response with the specified status code and object. The object will be JSON serialized.

Types

This section is empty.

Jump to

Keyboard shortcuts

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