2022-09-01 23:11:14 +00:00
|
|
|
package v1
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
|
|
"github.com/google/uuid"
|
2022-09-24 19:33:38 +00:00
|
|
|
"github.com/hay-kot/homebox/backend/pkgs/server"
|
2022-09-03 18:38:35 +00:00
|
|
|
"github.com/rs/zerolog/log"
|
2022-09-01 23:11:14 +00:00
|
|
|
)
|
|
|
|
|
2022-10-17 02:50:44 +00:00
|
|
|
func (ctrl *V1Controller) routeID(w http.ResponseWriter, r *http.Request) (uuid.UUID, error) {
|
|
|
|
ID, err := uuid.Parse(chi.URLParam(r, "id"))
|
2022-09-01 23:11:14 +00:00
|
|
|
if err != nil {
|
2022-09-03 18:38:35 +00:00
|
|
|
log.Err(err).Msg("failed to parse id")
|
2022-09-01 23:11:14 +00:00
|
|
|
server.RespondError(w, http.StatusBadRequest, err)
|
2022-10-17 02:50:44 +00:00
|
|
|
return uuid.Nil, err
|
2022-09-01 23:11:14 +00:00
|
|
|
}
|
|
|
|
|
2022-10-17 02:50:44 +00:00
|
|
|
return ID, nil
|
2022-09-01 23:11:14 +00:00
|
|
|
}
|