unireq

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckSuperfluousURLArgs

func CheckSuperfluousURLArgs(req *http.Request, allowedArgs []string) error

CheckSuperfluousURLArgs allows checking for presence of supported only arguments in URL. It returns first error it encounters.

func ClientIP added in v0.2.8

func ClientIP(req *http.Request) net.IP

ClientIP tries to capture actual remote client IP address even if the client communicates with proxy servers. Please note that the "forwarded" HTTP header is not supported.

In case nothing is found, nil is returned.

func GetURLBoolArgOrFail added in v0.3.12

func GetURLBoolArgOrFail(ctx *gin.Context, name string, dflt bool) (bool, bool)

GetURLBoolArgOrFail reads a string-encoded bool argument (= '1', '0') from URL query. If not set, then `dflt` is returned (i.e. value not present is considered a non-error). The second returned value is an "OK" flag. In case of an error, the function writes a HTTP response and returns false as a second argument.

func GetURLIntArgOrFail added in v0.3.12

func GetURLIntArgOrFail(ctx *gin.Context, name string, dflt int) (int, bool)

GetURLIntArgOrFail reads a string-encoded integer argument from URL query. If not set, then `dflt` is returned (i.e. value not present is considered a non-error). The second returned value is an "OK" flag. In case of an error, the function writes a HTTP response and returns false as a second argument.

Types

This section is empty.

Jump to

Keyboard shortcuts

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