validator

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDateNotInRange = newPublicError("Date submit is not in aceptable range")

ErrDateNotInRange error when date not in aceptable range

View Source
var ErrInvalidDigest = &gin.Error{
	Err:  errors.New("sha256 of body is not match with digest"),
	Type: gin.ErrorTypePublic,
}

ErrInvalidDigest error when sha256 of body do not match with submitted digest

Functions

This section is empty.

Types

type DateValidator

type DateValidator struct {
	// TimeGap is max time different between client submit timestamp
	// and webserve time that considered valid. The time precision is millisecond.
	TimeGap time.Duration
}

DateValidator checking validate by time range

func NewDateValidator

func NewDateValidator() *DateValidator

NewDateValidator return DateValidator with default value (30 second)

func (*DateValidator) Validate

func (v *DateValidator) Validate(r *http.Request) error

Validate return error when checking if header date is valid or not

type DigestValidator

type DigestValidator struct{}

DigestValidator checking digest in header match body

func NewDigestValidator

func NewDigestValidator() *DigestValidator

NewDigestValidator return pointer of new DigestValidator

func (*DigestValidator) Validate

func (v *DigestValidator) Validate(r *http.Request) error

Validate return error when checking digest match body

type Validator

type Validator interface {
	Validate(*http.Request) error
}

Validator interface for checking if a request is valid or not

Jump to

Keyboard shortcuts

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