jsonfmt

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package jsomfmt provides json format for file reading and http requests

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(r *http.Request, val interface{}) error

Decode reads the body of an HTTP request looking for a JSON document. The body is decoded into the provided value.

If the provided value is a struct then it is checked for validation tags.

func InputFile

func InputFile(jsonFileName string, val interface{}) error

InputFile for an inout json file reading and creating go values from it

func Output

func Output(w io.Writer, val interface{}) error

Output for outputting go values as json

func Respond

func Respond(ctx context.Context, w http.ResponseWriter, data interface{}, statusCode int) error

Respond converts a Go value to JSON and sends it

func RespondError

func RespondError(ctx context.Context, w http.ResponseWriter, err error) error

RespondError sends an error reponse back to the cli.

Types

This section is empty.

Jump to

Keyboard shortcuts

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