Documentation
¶
Index ¶
- Constants
- Variables
- func GetMailClient(f *form.Form) (*mail.Client, error)
- func SendFormConfirmation(f *form.Form, r string) error
- type CaptchaResponse
- type HcaptchaResponse
- type PingResponse
- type ReCaptchaResponse
- type Route
- func (r *Route) GetForm(i string) (form.Form, error)
- func (r *Route) GetToken(c echo.Context) error
- func (r *Route) Ping(c echo.Context) error
- func (r *Route) SendForm(c echo.Context) error
- func (r *Route) SendFormBindForm(next echo.HandlerFunc) echo.HandlerFunc
- func (r *Route) SendFormCheckToken(next echo.HandlerFunc) echo.HandlerFunc
- func (r *Route) SendFormHcaptcha(next echo.HandlerFunc) echo.HandlerFunc
- func (r *Route) SendFormHoneypot(next echo.HandlerFunc) echo.HandlerFunc
- func (r *Route) SendFormRecaptcha(next echo.HandlerFunc) echo.HandlerFunc
- func (r *Route) SendFormReqFields(next echo.HandlerFunc) echo.HandlerFunc
- func (r *Route) SendFormTurnstile(next echo.HandlerFunc) echo.HandlerFunc
- type SendFormRequest
- type SentSuccessful
- type TokenRequest
- type TokenResponse
- type TurnstileResponse
Constants ¶
const ( ErrNoValidObject = "no valid form object found" ErrHCaptchaValidateFailed = "hCaptcha validation failed" ErrReCaptchaVaildateFailed = "reCaptcha validation failed" ErrTurnstileVaildateFailed = "Turnstile validation failed" )
List of common errors
Variables ¶
var ( ErrReadHTTPResponseBody = "reading HTTP response body: %s" ErrJSONUnmarshal = "HTTP response JSON unmarshalling: %s" )
Functions ¶
func GetMailClient ¶ added in v0.2.4
GetMailClient returns a new mail dailer object based on the form configuration
Types ¶
type CaptchaResponse ¶
type CaptchaResponse struct { Success bool `json:"success"` ChallengeTimestamp string `json:"challenge_ts"` Hostname string `json:"hostname"` }
CaptchaResponse reflect the API response from various 3rd party captcha services
type HcaptchaResponse ¶
type HcaptchaResponse CaptchaResponse
HcaptchaResponse is the CaptchaResponse for hCaptcha
type PingResponse ¶
PingResponse reflects the JSON structure for a ping response
type ReCaptchaResponse ¶
type ReCaptchaResponse CaptchaResponse
ReCaptchaResponse is the CaptchaResponse for Google ReCaptcha
type Route ¶
Route represents an API route object
func (*Route) GetForm ¶
GetForm gets a form.Form object either from the in-memory cache or if not cached yet, from the file system
func (*Route) GetToken ¶
GetToken handles the HTTP token requests and return a TokenResponse on success or an error on failure
func (*Route) SendFormBindForm ¶
func (r *Route) SendFormBindForm(next echo.HandlerFunc) echo.HandlerFunc
SendFormBindForm is a middleware that validates the provided form data and binds it to a SendFormRequest object
func (*Route) SendFormCheckToken ¶
func (r *Route) SendFormCheckToken(next echo.HandlerFunc) echo.HandlerFunc
SendFormCheckToken is a middleware that checks the form security token
func (*Route) SendFormHcaptcha ¶
func (r *Route) SendFormHcaptcha(next echo.HandlerFunc) echo.HandlerFunc
SendFormHcaptcha is a middleware that checks the form data against hCaptcha
func (*Route) SendFormHoneypot ¶
func (r *Route) SendFormHoneypot(next echo.HandlerFunc) echo.HandlerFunc
SendFormHoneypot is a middleware that checks that a configured honeypot field is not filled with any data
func (*Route) SendFormRecaptcha ¶
func (r *Route) SendFormRecaptcha(next echo.HandlerFunc) echo.HandlerFunc
SendFormRecaptcha is a middleware that checks the form data against Google ReCaptcha
func (*Route) SendFormReqFields ¶
func (r *Route) SendFormReqFields(next echo.HandlerFunc) echo.HandlerFunc
SendFormReqFields is a middleware that validates that all required fields are set in the SendFormRequest object
func (*Route) SendFormTurnstile ¶ added in v0.3.0
func (r *Route) SendFormTurnstile(next echo.HandlerFunc) echo.HandlerFunc
SendFormTurnstile is a middleware that checks the form data against Cloudflare Turnstile
type SendFormRequest ¶
type SendFormRequest struct { FormID string `param:"fid"` FormObj *form.Form Token string `param:"token"` TokenResp *TokenResponse }
SendFormRequest reflects the structure of the send form request data
type SentSuccessful ¶ added in v0.2.2
type SentSuccessful struct { FormID string `json:"form_id"` SendTime int64 `json:"send_time"` ConfirmationSent bool `json:"confirmation_sent"` ConfirmationRcpt string `json:"confirmation_rcpt"` }
SentSuccessful represents confirmation JSON structure for a successfully sent message
type TokenRequest ¶
type TokenRequest struct {
FormID string `query:"formid" form:"formid"`
}
TokenRequest reflects the incoming gettoken request data that for the parameter binding
type TokenResponse ¶
type TokenResponse struct { Token string `json:"token"` FormID string `json:"form_id"` CreateTime int64 `json:"create_time,omitempty"` ExpireTime int64 `json:"expire_time,omitempty"` URL string `json:"url"` EncType string `json:"enc_type"` Method string `json:"method"` }
TokenResponse reflects the JSON response struct for token request
type TurnstileResponse ¶ added in v0.3.0
type TurnstileResponse CaptchaResponse
TurnstileResponse is the CaptchaResponse for Cloudflare Turnstile