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" )
Variables ¶
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") )
var ( // ErrRateLimitExceeded is thrown when an IP exceeds the // specified rate-limit ErrRateLimitExceeded = echo.NewHTTPError(http.StatusTooManyRequests, "Rate limit exceeded") )
var ErrVerificationFailure = echo.NewHTTPError(http.StatusInternalServerError, "Failed to perform email verification lookup")
ErrVerificationFailure is thrown when there is error while validating an email
Functions ¶
Types ¶
type Encoder ¶
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
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 ¶
NewService generates a new, fully populated Trumail reference