Help us shape the future of Go! Take the 2026 Go Developer Survey

api

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package api contains helpers to work with HTTP requests and responses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadJSON

func ReadJSON(r *http.Request, v interface{}) error

ReadJSON reads JSON from request.

func SendBadRequestError

func SendBadRequestError(w http.ResponseWriter, r *http.Request, message string)

SendBadRequestError sends a bad request error.

func SendError

func SendError(w http.ResponseWriter, r *http.Request, err error)

SendError sends a server error.

func SendNotFoundError

func SendNotFoundError(w http.ResponseWriter, r *http.Request)

SendNotFoundError sends a not found error.

func SendUnauthorizedError

func SendUnauthorizedError(w http.ResponseWriter, r *http.Request)

SendUnauthorizedError sends an unauthorized request error.

func WriteData

func WriteData(w http.ResponseWriter, httpStatusCode int, b []byte) error

WriteData responds with JSON.

func WriteJSON

func WriteJSON(w http.ResponseWriter, httpStatusCode int, v interface{}) error

WriteJSON responds with JSON.

Types

This section is empty.

Jump to

Keyboard shortcuts

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