Documentation
¶
Index ¶
Constants ¶
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" )
const AuthToken = "X-Auth-Token"
AuthToken is the key to be used on the Trumail Token header
Variables ¶
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") )
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 ErrorHandler ¶
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
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service contains all dependencies for the Trumail API
func NewService ¶
NewService generates a new, fully populated Trumail reference