api

package
v0.0.0-...-4112a1c Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2018 License: BSD-3-Clause Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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"
)
View Source
const AuthToken = "X-Auth-Token"

AuthToken is the key to be used on the Trumail Token header

Variables

View Source
var (
	// ErrVerificationFailure is thrown when there is error while validating an email
	ErrVerificationFailure = echo.NewHTTPError(http.StatusInternalServerError, "Failed to perform email verification lookup")
	// ErrUnsupportedFormat is thrown when the requestor has defined an unsupported response format
	ErrUnsupportedFormat = echo.NewHTTPError(http.StatusBadRequest, "Unsupported format")
	// ErrInvalidCallback is thrown when the request is missing the callback queryparam
	ErrInvalidCallback = echo.NewHTTPError(http.StatusBadRequest, "Invalid callback query param provided")
)
View Source
var (
	// ErrRateLimitExceeded is thrown when an IP exceeds the
	// specified rate-limit
	ErrRateLimitExceeded = echo.NewHTTPError(http.StatusTooManyRequests,
		"Rate limit exceeded - If you'd like a higher request volume please contact pricing@trumail.io")
)

Functions

func Debug

func Debug(c echo.Context) error

Debug is an endpoint for debugging runaway goroutines

func ErrorHandler

func ErrorHandler(err error, c echo.Context)

ErrorHandler is a custom error handler that will redirect all 404s back to https://trumail.io

Types

type Health

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

Health is a healthcheck response body

type LimitStatus

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

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(token string, max int64, interval time.Duration) *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 {
	// contains filtered or unexported fields
}

Service contains all dependencies for the Trumail API

func NewService

func NewService(l *logrus.Logger, sourceAddr string, timeout int) *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