Documentation
¶
Index ¶
- Constants
- Variables
- func CORSMiddleware(next http.HandlerFunc) http.HandlerFunc
- func LogAndRecoverMiddleware(next http.HandlerFunc) http.HandlerFunc
- func MiddlewareWrap(handler http.HandlerFunc, ...) http.HandlerFunc
- func Retry(retries int, backOff time.Duration, fn func() error) error
- type ContextKey
- type Entry
- type HttpRequestLog
- type JSONLogHandler
- type ReCaptcha
- type RecaptchaVersion
- type RequestContext
- type SiteVerifyResponse
- type VerifyError
- type VerifyOptions
Constants ¶
View Source
const ( ReCaptchaURL = "https://www.google.com/recaptcha/api/siteverify" TurnstileURL = "https://challenges.cloudflare.com/turnstile/v0/siteverify" )
Variables ¶
View Source
var DefaultJSONLogHandler = NewJSONLogHandler(os.Stderr)
View Source
var ErrNeverTried = errors.New("never tried")
View Source
var RequestCtxKey = &ContextKey{name: "RequestContext"}
Functions ¶
func CORSMiddleware ¶
func CORSMiddleware(next http.HandlerFunc) http.HandlerFunc
func LogAndRecoverMiddleware ¶
func LogAndRecoverMiddleware(next http.HandlerFunc) http.HandlerFunc
func MiddlewareWrap ¶
func MiddlewareWrap(handler http.HandlerFunc, middlewares ...func(http.HandlerFunc) http.HandlerFunc) http.HandlerFunc
Types ¶
type ContextKey ¶
type ContextKey struct {
// contains filtered or unexported fields
}
func (ContextKey) String ¶
func (key ContextKey) String() string
type HttpRequestLog ¶
type HttpRequestLog struct {
Timestamp time.Time `json:"-"`
Latency string `json:"latency,omitempty"`
Protocol string `json:"protocol,omitempty"`
Referer string `json:"referer,omitempty"`
RemoteIp string `json:"remoteIp,omitempty"`
RequestMethod string `json:"requestMethod,omitempty"`
RequestUrl string `json:"requestUrl,omitempty"`
UserAgent string `json:"userAgent,omitempty"`
ServerIp string `json:"serverIp,omitempty"`
}
func (*HttpRequestLog) Finalize ¶
func (reqLog *HttpRequestLog) Finalize()
type JSONLogHandler ¶
func NewJSONLogHandler ¶
func NewJSONLogHandler(w io.Writer) *JSONLogHandler
type ReCaptcha ¶
type ReCaptcha struct {
Client http.Client
Secret string
Version RecaptchaVersion
}
type RecaptchaVersion ¶
type RecaptchaVersion string
const ( ReCaptchaV2 RecaptchaVersion = "v2" ReCaptchaV3 RecaptchaVersion = "v3" ReCaptchaCf RecaptchaVersion = "cf" )
type RequestContext ¶
type RequestContext struct {
RequestLog *HttpRequestLog
LogEntry *log.Entry
}
type SiteVerifyResponse ¶
type VerifyError ¶
func (VerifyError) Error ¶
func (err VerifyError) Error() string
type VerifyOptions ¶
Click to show internal directories.
Click to hide internal directories.