Documentation
¶
Overview ¶
Package jason wraps around encoding/json to make it easier to read and write JSON in Go web APIs
Package jason wraps around encoding/json to make it easier to read and write JSON in Go web APIs
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Read ¶
func Read(w http.ResponseWriter, r *http.Request, params ReadParams) error
func Write ¶
func Write(w http.ResponseWriter, params WriteParams) error
Write sends an HTTP response using the provided http.ResponseWriter and WriteParams. It serializes the data in WriteParams.Data to JSON format, sets the HTTP status code, and adds any custom HTTP headers specified in WriteParams.Headers to the response.
Parameters:
- w: An http.ResponseWriter to write the HTTP response to.
- params: A WriteParams struct containing data, status code, and headers.
Returns:
- error: An error if there was an issue serializing the data or writing the response.
Types ¶
type ReadParams ¶ added in v0.1.3
Click to show internal directories.
Click to hide internal directories.