middlewares

package
v0.0.0-...-1de268a Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Get([]byte) ([]byte, error)
	Set([]byte, []byte, int) error
}

type CompanyCtx

type CompanyCtx struct {
	// contains filtered or unexported fields
}

CompanyCtx is a middleware used to load Company to context.

func NewCompanyCtx

func NewCompanyCtx(r handlers.CompaniesRepo) *CompanyCtx

NewCompanyCtx creates an instance of CompanyCtx middleware.

func (*CompanyCtx) Handle

func (c *CompanyCtx) Handle(next http.Handler) http.Handler

Handle is used to load an Company object from the URL parameters passed through in the request. In case the Company could not be found, we stop here and return a 404.

type CompanyPayloadCtx

type CompanyPayloadCtx struct {
	// contains filtered or unexported fields
}

CompanyCtx is a middleware used to validate incoming Company payload data.

func NewCompanyPayloadCtx

func NewCompanyPayloadCtx(v *validator.Validation, queryDecoder *schema.Decoder) *CompanyPayloadCtx

NewCompanyPayloadCtx creates an instance of CompanyPayloadCtx middleware.

func (*CompanyPayloadCtx) Handle

func (c *CompanyPayloadCtx) Handle(next http.Handler) http.Handler

Handle is used to validate incoming Company payload data. In case payload is invalid, we return formatted errors.

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

type Ipapi

type Ipapi struct {
	// contains filtered or unexported fields
}

Ipapi is a middleware that fetches the country code for request IP address, and verifies if it's allowed to proceed.

func NewIpapi

func NewIpapi(config *configs.Config, httpClient HTTPClient, cache Cache) *Ipapi

NewIpapi creates an instance of Ipapi middleware.

func (*Ipapi) Handle

func (i *Ipapi) Handle(next http.Handler) http.Handler

Handle used to fetch the country code for request IP address, and verifies if it's allowed to proceed.

Jump to

Keyboard shortcuts

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