defaults

package
v0.0.0-...-bde724d Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: MIT-0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrValueNotFound is the error returned from the Get* functions
	// when this value was not found in the request.
	ErrValueNotFound = errors.New("value not found")
)

Functions

func DecodeBody

func DecodeBody(req *http.Request, obj any) error

DecodeBody uses a json decoder to decode the body of the request into the target object.

func DerefType

func DerefType(obj any) (reflect.Type, bool)

DerefType dereferences the type of the object if it is a pointer or an interface. Returns whether the final type is a struct.

func DerefValue

func DerefValue(obj any) (reflect.Value, bool)

DerefValue dereferences the value of the object until it is no longer a pointer or an interface. Also returns false if the underlying value is Nil.

func GenVal

func GenVal(t reflect.Type, value string, values ...string) (reflect.Value, error)

GenVal generates an any from the string values given.

func GetCookie

func GetCookie(req *http.Request, key string) (string, error)

GetCookie returns the value of the cookie by the name given.

func GetHeader

func GetHeader(req *http.Request, key string) (string, error)

GetHeader returns the value of the header if it was found.

func GetQueries

func GetQueries(req *http.Request, key string) ([]string, error)

GetQueries returns the list of values that this query parameter had in the request.

func GetSegment

func GetSegment(req *http.Request, key string) (string, error)

GetSegment returns ErrValueNotFound because we have no way of knowing how the server mux has altered the request to let this information resurface.

Types

This section is empty.

Jump to

Keyboard shortcuts

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