validator

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2019 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDateNotInRange = errors.New("Date submit is not in aceptable range")

ErrDateNotInRange error when date not in aceptable range

View Source
var ErrInvalidDigest = errors.New("Sha256 of body is not match with digest")

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 server 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