// HTTPNew fiber handler for new captcha
HTTPNew fiber handler for new captcha
// HTTPNew fiber handler for new captcha
func HTTPNew(c *fiber.Ctx, config *Config, storage *Storage) error {
	r := new(NewRequest)
	if err := c.BodyParser(r); err != nil {
		return err
	}
	if r.TTL < 30 {
		r.TTL = 30
	} else if r.TTL >= 600 {
		r.TTL = 600
	}
	item := storage.NewItem(GetLevel(r.Level), r.Lang, r.TTL)
	image := GenerateCaptcha(item)
	response := NewResponse{ID: item.ID, Image: image, Expire: item.Expire.Format(time.RFC3339), Value: 0}
	if config.ReturnValue {
		response.Value = item.Value
	}
	PrometheusShowTotal.Inc()
	return c.JSON(response)
}
func HTTPNew ( c * fiber . Ctx , config * Config , storage * Storage ) error { r := new ( NewRequest ) if err := c . BodyParser ( r ) ; err != nil { return err } if r . TTL < 30 { r . TTL = 30 } else if r . TTL >= 600 { r . TTL = 600 } item := storage . NewItem ( GetLevel ( r . Level ) , r . Lang , r . TTL ) image := GenerateCaptcha ( item ) response := NewResponse { ID : item . ID , Image : image , Expire : item . Expire . Format ( time . RFC3339 ) , Value : 0 } if config . ReturnValue { response . Value = item . Value } PrometheusShowTotal . Inc ( ) return c . JSON ( response ) }
HTTPNew fiber handler for new captcha
HTTPNew fiber handler for new captcha