API: Update endpoints to return HTTP 201 when a new resource was created

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-10-20 16:46:59 +02:00
parent ddc37e08ab
commit ce304abd2c
12 changed files with 194 additions and 30 deletions

View File

@@ -30,7 +30,7 @@ import (
// @Produce json
// @Param uid path string true "user uid"
// @Param request body form.Passcode true "passcode setup (password required)"
// @Success 200 {object} entity.Passcode
// @Success 201 {object} entity.Passcode
// @Failure 400,401,403,429 {object} i18n.Response
// @Router /api/v1/users/{uid}/passcode [post]
func CreateUserPasscode(router *gin.RouterGroup) {
@@ -84,7 +84,8 @@ func CreateUserPasscode(router *gin.RouterGroup) {
event.AuditInfo([]string{ClientIP(c), "session %s", authn.Users, user.UserName, authn.Passcode, authn.Created}, s.RefID)
c.JSON(http.StatusOK, passcode)
header.SetLocation(c)
c.JSON(http.StatusCreated, passcode)
})
}