request

package
v0.0.0-...-3a75ae7 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// FormDecoder is used to decode url.Values in the DecodeForm.
	FormDecoder = form.NewDecoder()

	// Validator is used both for JSON and Form validation.
	Validator = validator.New(validator.WithRequiredStructEnabled())
)

Functions

func DecodeForm

func DecodeForm[T any](r *http.Request) (*T, error)

DecodeForm converts a url.Values (including form values) from the incoming request r into the struct v.

The decoded struct is validated with the Validator.

Use validation tags from the github.com/go-playground/validator/v10 for setting validation.

func DecodeJSON

func DecodeJSON[T any](r *http.Request) (*T, error)

DecodeJSON converts a JSON body from the incoming request r into the struct v.

The decoded struct is validated with the Validator.

Use validation tags from the github.com/go-playground/validator/v10 for setting validation.

Types

This section is empty.

Jump to

Keyboard shortcuts

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