render

package
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package render provides HTTP output rendering helper functions.

Index

Constants

View Source
const JSONContentType = "application/json"

JSONContentType represents MIME type for JSON content.

Variables

This section is empty.

Functions

func JSON

func JSON(rw http.ResponseWriter, code int, v any) error

JSON writes a JSON response.

func JSONError

func JSONError(rw http.ResponseWriter, code int, reason string)

JSONError writes a JSON error message.

func JSONErrorf

func JSONErrorf(rw http.ResponseWriter, code int, format string, args ...any)

JSONErrorf writes a JSON error message.

func JSONInternalServerError

func JSONInternalServerError(rw http.ResponseWriter)

JSONInternalServerError writes a JSON internal server error.

Types

type APIError

type APIError struct {
	Code   int    `json:"code"`
	Reason string `json:"reason"`
}

APIError contains error information that is rendered by JSONError.

Jump to

Keyboard shortcuts

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