REST API: add location header to 201 responses

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2022-12-23 13:08:04 +01:00
parent ed949604d3
commit e5a8220b8a
8 changed files with 63 additions and 36 deletions

View File

@@ -16,6 +16,7 @@ package httpd
import (
"context"
"fmt"
"net/http"
"github.com/go-chi/render"
@@ -58,6 +59,7 @@ func addGroup(w http.ResponseWriter, r *http.Request) {
sendAPIResponse(w, r, err, "", getRespStatus(err))
return
}
w.Header().Add("Location", fmt.Sprintf("%s/%s", groupPath, group.Name))
renderGroup(w, r, group.Name, http.StatusCreated)
}