request

package
v0.0.0-...-fb47ef5 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: Apache-2.0 Imports: 10 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PathVarsFunc = func(r *http.Request) PathVarList {
	return nil
}
View Source
var ValidateBody = func(r *http.Request, data any) error {
	return nil
}

Functions

func Body

func Body(r *http.Request, into any) error
func Header[T any](r *http.Request, key string, defaultValue T) T

func HeaderOrQuery

func HeaderOrQuery[T any](r *http.Request, key string, defaultValue T) T

func Path

func Path[T any](r *http.Request, key string, defaultValue T) T

func Query

func Query[T any](r *http.Request, key string, defaultValue T) T

func ValueOrDefault

func ValueOrDefault[T any](val string, defaultValue T) T

nolint: forcetypeassert,gomnd,ifshort ValueOrDefault return default value if empty string

Types

type ListOptions

type ListOptions struct {
	Page   int    `json:"page,omitempty"`
	Size   int    `json:"size,omitempty"`
	Search string `json:"search,omitempty"`
	Sort   string `json:"sort,omitempty"`
}

func GetListOptions

func GetListOptions(r *http.Request) ListOptions

nolint: gomnd

type PathVar

type PathVar struct {
	Key   string `json:"key,omitempty"`
	Value string `json:"value,omitempty"`
}

type PathVarList

type PathVarList []PathVar

func PathVars

func PathVars(r *http.Request) PathVarList

func (PathVarList) Get

func (p PathVarList) Get(key string) string

func (PathVarList) Map

func (p PathVarList) Map() map[string]string

Jump to

Keyboard shortcuts

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