mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-25 02:09:01 +02:00
fix(api): validate API response
This commit is contained in:
@@ -27,7 +27,7 @@ type ValidateFileRequest struct {
|
|||||||
// @Success 200 {object} apitypes.SuccessResponse "File validated"
|
// @Success 200 {object} apitypes.SuccessResponse "File validated"
|
||||||
// @Failure 400 {object} apitypes.ErrorResponse "Bad request"
|
// @Failure 400 {object} apitypes.ErrorResponse "Bad request"
|
||||||
// @Failure 403 {object} apitypes.ErrorResponse "Forbidden"
|
// @Failure 403 {object} apitypes.ErrorResponse "Forbidden"
|
||||||
// @Failure 417 {object} apitypes.ErrorResponse "Validation failed"
|
// @Failure 417 {object} any "Validation failed"
|
||||||
// @Failure 500 {object} apitypes.ErrorResponse "Internal server error"
|
// @Failure 500 {object} apitypes.ErrorResponse "Internal server error"
|
||||||
// @Router /file/validate [post]
|
// @Router /file/validate [post]
|
||||||
func Validate(c *gin.Context) {
|
func Validate(c *gin.Context) {
|
||||||
@@ -45,7 +45,7 @@ func Validate(c *gin.Context) {
|
|||||||
c.Request.Body.Close()
|
c.Request.Body.Close()
|
||||||
|
|
||||||
if valErr := validateFile(request.FileType, content); valErr != nil {
|
if valErr := validateFile(request.FileType, content); valErr != nil {
|
||||||
c.JSON(http.StatusExpectationFailed, apitypes.Error("invalid file", valErr))
|
c.JSON(http.StatusExpectationFailed, valErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, apitypes.Success("file validated"))
|
c.JSON(http.StatusOK, apitypes.Success("file validated"))
|
||||||
|
|||||||
Reference in New Issue
Block a user