homebox/backend/app/api/handlers/v1/partials.go

22 lines
467 B
Go
Raw Normal View History

2022-09-01 23:11:14 +00:00
package v1
import (
"net/http"
"github.com/go-chi/chi/v5"
"github.com/google/uuid"
"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
)
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)
return uuid.Nil, err
2022-09-01 23:11:14 +00:00
}
return ID, nil
2022-09-01 23:11:14 +00:00
}