package fr.titionfire;

import io.quarkus.qute.Template;
import io.smallrye.mutiny.Uni;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.eclipse.microprofile.openapi.annotations.Operation;

import static java.util.Objects.requireNonNull;

@Path("api/some-page")
public class SomePage {

    private final Template page;

    public SomePage(Template page) {
        this.page = requireNonNull(page, "page is required");
    }

    @GET
    @Produces(MediaType.TEXT_HTML)
    @Operation(hidden = true)
    public Uni<String> get() {
        return Uni.createFrom()
                .completionStage(() -> page
                        .data("name", "test")
                        .renderAsync());
    }

}
