Documentation ¶
Index ¶
Constants ¶
const ( ContentType = "Content-Type" ContentTypeJSON = "application/json" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Envelope ¶
Envelope wraps JSON data for marshalling purposes, guarding against subtle JSON vulnerabilities. For more information, refer to: https://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx/
type Err ¶ added in v1.0.0
type Err struct { // Code is the recommended error code for error handling. It represents an HTTP status code, // providing guidance on how to handle the error, such as returning it to the client or logging it. Code int `json:"code"` // Msg contains the error message, providing detailed information about the encountered error. Msg string `json:"msg"` }
Err represents an error with an associated code and message
type Jason ¶
type Jason struct {
// contains filtered or unexported fields
}
Jason represents a configuration for handling JSON requests and responses
func (*Jason) Read ¶
Read reads JSON data from the request body and decodes it into the provided destination interface. It checks the content type of the request and ensures that the destination is a pointer. Additionally, it sets limits on the request body size and handles various decoding errors.
func (*Jason) Write ¶
Write writes the JSON representation of the provided Envelope data to the given http.ResponseWriter. It sets the HTTP status code, headers, and writes the JSON data. If indentation is enabled, it marshals data with indentation. Otherwise, it marshals data without indentation. The provided headers are set to the response writer before writing the data.