added swagger doc for get avatar
parent
ea00255125
commit
a70e2e32d0
|
@ -11,11 +11,26 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetAvatar(c *fiber.Ctx) error {
|
func GetAvatar(c *fiber.Ctx) error {
|
||||||
|
// swagger:operation GET /avatars/:userId/:fileName?size= user userGetAvatar
|
||||||
|
// ---
|
||||||
|
// summary: Get avatar from a user
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// responses:
|
||||||
|
// '200':
|
||||||
|
// description: Avatar from user
|
||||||
|
// '400':
|
||||||
|
// description: Avatar does not exist
|
||||||
|
// '422':
|
||||||
|
// description: Invalid userId or fileName
|
||||||
|
|
||||||
userId := c.Params("userId")
|
userId := c.Params("userId")
|
||||||
|
|
||||||
if len(userId) != structs.LenUserId {
|
if len(userId) != structs.LenUserId {
|
||||||
logrus.Debugln("UserId is longer than allowed")
|
logrus.Debugln("UserId is longer than allowed")
|
||||||
return c.SendStatus(fiber.StatusBadRequest)
|
return c.SendStatus(fiber.StatusUnprocessableEntity)
|
||||||
}
|
}
|
||||||
|
|
||||||
fileName := c.Params("fileName")
|
fileName := c.Params("fileName")
|
||||||
|
@ -23,7 +38,7 @@ func GetAvatar(c *fiber.Ctx) error {
|
||||||
// check if the filename length has not been manipulated by the user
|
// check if the filename length has not been manipulated by the user
|
||||||
if len(fileName) > image.MaxFileNameLen {
|
if len(fileName) > image.MaxFileNameLen {
|
||||||
logrus.Debugln("Filename is longer than allowed")
|
logrus.Debugln("Filename is longer than allowed")
|
||||||
return c.SendStatus(fiber.StatusBadRequest)
|
return c.SendStatus(fiber.StatusUnprocessableEntity)
|
||||||
}
|
}
|
||||||
|
|
||||||
// image resolution
|
// image resolution
|
||||||
|
|
Loading…
Reference in New Issue