render

package
v0.4.1-0...-6027f60 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2025 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Accept      = "Accept"
	ContentType = "Content-Type"
)

Header keys for http requests and responses

Variables

This section is empty.

Functions

func Accepted

func Accepted(r *http.Request) []string

func JSON

func JSON(code int, w http.ResponseWriter, obj any) error

JSON marshals the given interface object and writes it with the correct ContentType.

func MsgPack

func MsgPack(code int, w http.ResponseWriter, obj msgp.Encodable) error

MsgPack marshals the given interface object to the binary MessagePack representation and writes it to the response with the correct ContentType

func ParseAccept

func ParseAccept(acceptHeader string) []string

func Text

func Text(code int, w http.ResponseWriter, text string) error

func Textf

func Textf(code int, w http.ResponseWriter, text string, a ...any) error

Types

type Renderer

type Renderer interface {
	Render(code int, w http.ResponseWriter, obj any) error
}

func Negotiate

func Negotiate(r *http.Request) Renderer

Jump to

Keyboard shortcuts

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