package restimage

import (
	"context"
	"io"
	"net/http"

	"git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/components/images"
)

type Handler struct {
	http.Handler
	img imageService
}

func New(srv imageService) *Handler {
	mux := http.NewServeMux()
	h := &Handler{
		Handler: mux,
		img:     srv,
	}

	mux.HandleFunc("GET /images/{uid}", h.getImage)
	return h
}

type imageService interface {
	GetScaledImage(ctx context.Context, uid string, options images.Options) (img io.Reader, mimeType string, err error)
}
