nidus-sync/rmo/image.go

25 lines
551 B
Go
Raw Normal View History

package rmo
2026-01-21 18:26:48 +00:00
import (
"net/http"
"github.com/Gleipnir-Technology/nidus-sync/userfile"
"github.com/go-chi/chi/v5"
"github.com/google/uuid"
2026-01-21 18:26:48 +00:00
)
// ServeImageByUUID reads an image with the given UUID from disk and writes it to the HTTP response
func getImageByUUID(w http.ResponseWriter, r *http.Request) {
u := chi.URLParam(r, "uuid")
if u == "" {
2026-01-21 18:26:48 +00:00
http.NotFound(w, r)
return
}
uid, err := uuid.Parse(u)
if err != nil {
http.Error(w, "Failed to parse uuid", http.StatusBadRequest)
return
}
2026-01-21 18:26:48 +00:00
userfile.PublicImageFileToResponse(w, uid)
}