api

package
v0.0.0-...-d77a28c Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2019 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FormatJSON is the format constant for a JSON output
	FormatJSON = "json"
	// FormatJSONP is the format constant for a JSONP output
	FormatJSONP = "jsonp"
	// FormatXML is the format constant for a XML output
	FormatXML = "xml"
)

Variables

View Source
var (
	// ErrInvalidCallback is thrown when the request is missing the callback queryparam
	ErrInvalidCallback = echo.NewHTTPError(http.StatusBadRequest, "Invalid callback query param provided")
	// ErrUnsupportedFormat is thrown when the requestor has defined an unsupported response format
	ErrUnsupportedFormat = echo.NewHTTPError(http.StatusBadRequest, "Unsupported format")
)
View Source
var (
	// ErrRateLimitExceeded is thrown when an IP exceeds the
	// specified rate-limit
	ErrRateLimitExceeded = echo.NewHTTPError(http.StatusTooManyRequests,
		"Rate limit exceeded")
)
View Source
var ErrVerificationFailure = echo.NewHTTPError(http.StatusInternalServerError, "Failed to perform email verification lookup")

ErrVerificationFailure is thrown when there is error while validating an email

Functions

func DefaultEncoder

func DefaultEncoder(c echo.Context, code int, res interface{}) error

DefaultEncoder is an encoder that reads the format from the passed echo context and writes the status code and response based on that format

Types

type Encoder

type Encoder func(c echo.Context, code int, res interface{}) error

Encoder is a function type that encodes a response given a context, a status code and a response

type Health

type Health struct {
	Status string `json:"status"`
}

Health is a healthcheck response body

type LimitStatus

type LimitStatus struct {
	Max      int64         `json:"max"`
	Interval time.Duration `json:"interval"`
	Current  int64         `json:"current"`
}

LimitStatus is returned when a request is made for an IPs current rate limit standing

type RateLimiter

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

RateLimiter is a middleware for limiting request speed to a maximum over a set interval

func NewRateLimiter

func NewRateLimiter(max int64, interval time.Duration, cidrcustom string) *RateLimiter

NewRateLimiter generates a new RateLimiter reference

func (*RateLimiter) LimitStatus

func (r *RateLimiter) LimitStatus(c echo.Context) error

LimitStatus retrieves and returns general Trumail statistics

func (*RateLimiter) RateLimit

func (r *RateLimiter) RateLimit(next echo.HandlerFunc) echo.HandlerFunc

RateLimit returns an error if the ip passed has performed too many requests in the defined period of time.

type ReqData

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

ReqData contains recent request data

func NewReqData

func NewReqData() *ReqData

NewReqData generates a new ReqData reference with the start time

func (*ReqData) Count

func (f *ReqData) Count()

Count increments the count on a ReqData

type Service

type Service struct {
	Logger   *logrus.Entry
	Encode   Encoder
	Timeout  time.Duration
	Verifier *verifier.Verifier
}

Service contains all dependencies for the Trumail API

func NewService

func NewService(l *logrus.Logger, timeout int, v *verifier.Verifier) *Service

NewService generates a new, fully populated Trumail reference

func (*Service) Health

func (s *Service) Health(c echo.Context) error

Health returns a Health check response indicating the health state of the service

func (*Service) Lookup

func (s *Service) Lookup(c echo.Context) error

Lookup performs a single email verification and returns a fully populated lookup or an error

Jump to

Keyboard shortcuts

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