response

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeHeader = "Content-Type"
	ContentTypeJSON   = "application/json"
)

ContentType header possible values

Variables

This section is empty.

Functions

func WriteJSON

func WriteJSON(w http.ResponseWriter, value interface{}, status int) error

WriteJSON set the content type header to JSON, writes the response object as json and sets the http status code.

Types

type JSONEncoder

type JSONEncoder interface {
	WriteResponseJSON(w http.ResponseWriter, value interface{}, status int) error
}

JSONEncoder interface defining a JSON encoder.

var JsonResponseEncoder JSONEncoder = &OnsJSONEncoder{}

type OnsJSONEncoder

type OnsJSONEncoder struct{}

OnsJSONEncoder is a JSON encoder

func (*OnsJSONEncoder) WriteResponseJSON

func (j *OnsJSONEncoder) WriteResponseJSON(w http.ResponseWriter, value interface{}, status int) error

WriteResponseJSON marshals the provided value as json body, and sets the status code to the provided value

Jump to

Keyboard shortcuts

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