Documentation ¶
Index ¶
- Constants
- type Captcha
- type CaptchaServerSettings
- type CheckCaptchaRequest
- type CheckCaptchaResponse
- type CreateCaptchaRequest
- type CreateCaptchaResponse
- type ErrorWithHttpStatusCode
- type GetCaptchaImageRequest
- type GetCaptchaImageResponse
- type HasCaptchaRequest
- type HasCaptchaResponse
- type ICaptchaServer
- type IEasyServer
- type IRegistry
- type RegistrySettings
Constants ¶
View Source
const ( ImageFileExt = "png" FileExtFullPng = "." + ImageFileExt ImageFormat = "PNG" ImageMimeType = "image/png" QueryKeyId = "id" RUIDPrefix = "RCS-" CaptchaImageMinWidth = 128 CaptchaImageMinHeight = 128 RingMinCount = 3 RingMaxCount = 6 RingMinRadius = 24 BrushOuterRadiusMin = 2 BrushOuterRadiusMax = 32 ColourComponentMaxValue = 65535 KR = 0.5 KDMin = 1.0 KDMax = 1.5 // C1 is a maximum colour channel value of a pixel in an 'image.RGBA' of // the built-in library. C1 = float64(65_535) )
View Source
const ( Err_Anomaly = "anomaly" Err_BrushRadiusRatio = "brush radius ratio error" Err_CacheSettingsError = "error in cache settings" Err_CanvasIsTooSmall = "canvas is too small" Err_DensityCoefficient = "density coefficient error" Err_Dimensions = "dimensions error" ErrF_FileExtensionMismatch = "file extension mismatch: png vs %s" Err_FileStorageIsDisabled = "file storage is disabled" Err_IdIsDuplicate = "duplicate ID" Err_IdIsNotFound = "ID is not found" Err_IdIsNotSet = "ID is not set" Err_ImageFormatIsInvalid = "image format is invalid" Err_ImagesFolderIsNotSet = "images folder is not set" Err_ImagesHaveDifferentDimensions = "images have different dimensions" Err_ImageHeightIsNotSet = "image height is not set" Err_ImageWidthIsNotSet = "image width is not set" Err_RequestIsAbsent = "request is absent" )
View Source
const ( Msg_CaptchaManagerStart = "Captcha manager has started" Msg_CaptchaManagerStop = "Captcha manager has been stopped" Msg_CleaningImagesFolder = "Cleaning the images folder ... " Msg_Done = "Done" Msg_Failure = "Failure" Msg_ImageCleanerHasStarted = "image cleaner has started" Msg_ImageCleanerHasStopped = "image cleaner has stopped" MsgF_CleaningImages = "cleaning %v images ... " )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Captcha ¶
type Captcha struct { Id string Image *image.NRGBA ImageData []byte ImageFormat string RingCount uint }
func NewCaptchaWithId ¶
type CaptchaServerSettings ¶
type CaptchaServerSettings struct { // Main settings. IsImageStorageUsed bool IsImageServerEnabled bool IsImageCleanupAtStartUsed bool IsStorageCleaningEnabled bool // Image settings. ImagesFolder string ImageWidth uint ImageHeight uint FilesCountToClean int // HTTP server settings. HttpHost string HttpPort uint16 HttpErrorsChan *chan error HttpServerName string // File cache settings. FileCacheSizeLimit int FileCacheVolumeLimit int FileCacheItemTtl uint // Record cache settings. RecordCacheSizeLimit int RecordCacheItemTtl uint }
func (*CaptchaServerSettings) Check ¶
func (s *CaptchaServerSettings) Check() (err error)
type CheckCaptchaRequest ¶
func (*CheckCaptchaRequest) Check ¶
func (req *CheckCaptchaRequest) Check() (err error)
type CheckCaptchaResponse ¶
type CreateCaptchaRequest ¶
type CreateCaptchaRequest struct{}
type CreateCaptchaResponse ¶
type CreateCaptchaResponse struct { TaskId string ImageFormat string // When storage is used, images are not returned in response objects; // instead, they are manually requested by clients from storage. Opposite // is also true: when storage is not used, server returns images in // response objects. IsImageDataReturned bool ImageData []byte }
type ErrorWithHttpStatusCode ¶
type ErrorWithHttpStatusCode struct {
// contains filtered or unexported fields
}
func NewErrorWithHttpStatusCode ¶
func NewErrorWithHttpStatusCode(msg string, httpStatusCode int) *ErrorWithHttpStatusCode
func NewErrorWithHttpStatusCodeFromError ¶
func NewErrorWithHttpStatusCodeFromError(e error) *ErrorWithHttpStatusCode
func (*ErrorWithHttpStatusCode) Error ¶
func (e *ErrorWithHttpStatusCode) Error() string
func (*ErrorWithHttpStatusCode) GetHttpStatusCode ¶
func (e *ErrorWithHttpStatusCode) GetHttpStatusCode() int
type GetCaptchaImageRequest ¶
type GetCaptchaImageRequest struct {
TaskId string
}
func NewGetImageRequestFromHttpRequest ¶
func NewGetImageRequestFromHttpRequest(httpReq *http.Request) (req *GetCaptchaImageRequest, err error)
func (*GetCaptchaImageRequest) Check ¶
func (req *GetCaptchaImageRequest) Check() (err error)
type GetCaptchaImageResponse ¶
type HasCaptchaRequest ¶
type HasCaptchaRequest struct {
TaskId string
}
func (*HasCaptchaRequest) Check ¶
func (req *HasCaptchaRequest) Check() (err error)
type HasCaptchaResponse ¶
type ICaptchaServer ¶
type ICaptchaServer interface { Start() (err error) Stop() (err error) GetListenDsn() (dsn string) CreateCaptcha() (resp *CreateCaptchaResponse, err error) CheckCaptcha(req *CheckCaptchaRequest) (resp *CheckCaptchaResponse, err error) HasCaptcha(req *HasCaptchaRequest) (resp *HasCaptchaResponse, err error) GetCaptchaImage(req *GetCaptchaImageRequest) (resp *GetCaptchaImageResponse, err error) }
type IEasyServer ¶
type RegistrySettings ¶
type RegistrySettings struct { // Main settings. IsImageStorageUsed bool IsStorageCleaningEnabled bool // Image settings. ImagesFolder string FilesCountToClean int // File cache settings. FileCacheSizeLimit int FileCacheVolumeLimit int FileCacheItemTtl uint // Record cache settings. RecordCacheSizeLimit int RecordCacheItemTtl uint }
Click to show internal directories.
Click to hide internal directories.