utils

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractIP

func ExtractIP(r *http.Request) string

ExtractIP default method to return ip from request

func Float64Equal added in v0.10.8

func Float64Equal(f1, f2 float64) bool

Float64Equal tests if two numbers are equal

func GetIPHeader

func GetIPHeader(r *http.Request) string

GetIPHeader returns ip header

func HashKey added in v0.10.3

func HashKey(k string) string

func NewTransport

func NewTransport() http.RoundTripper

NewTransport creates new roundtriper with same MaxIdleConnsPerHost ready to be used for access to only one host

func ParseDateParam

func ParseDateParam(s string) (*time.Time, error)

ParseDateParam parse query param or returns echo error

func ParseURL

func ParseURL(str string) (*url.URL, error)

ParseURL parse url and checks host is not empty

func StartOfMonth

func StartOfMonth(now time.Time, next int) time.Time

StartOfMonth returns the time when month starts

func TakeJSONInput

func TakeJSONInput(c echo.Context, input interface{}) error

TakeJSONInput extracts request body to 'input' as json object, checks for correct mime type

func ValidateIPInWhiteList

func ValidateIPInWhiteList(ips, ip string) (bool, error)

ValidateIPInWhiteList check if IPs is in valid range of white lists

func ValidateIPsCIDR

func ValidateIPsCIDR(ip string) error

ValidateIPsCIDR check if IPs are valid comma separated CIDR format

Types

type IPExtractor

type IPExtractor interface {
	Get(*http.Request) string
}

IPExtractor extracts IP from request

var DefaultIPExtractor IPExtractor = &firstForwardFor{}

DefaultIPExtractor default implementation

func NewIPExtractor

func NewIPExtractor(ipType string) (IPExtractor, error)

NewIPExtractor creates new extractor based on type

Jump to

Keyboard shortcuts

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