package de.arindy.dicetower

import io.quarkus.qute.TemplateInstance
import jakarta.ws.rs.GET
import jakarta.ws.rs.Path
import jakarta.ws.rs.PathParam
import jakarta.ws.rs.Produces
import jakarta.ws.rs.QueryParam
import jakarta.ws.rs.core.MediaType

@Path("overlay/{diceid}")
class OverlayResource {

    @GET
    @Produces(MediaType.TEXT_HTML)
    fun get(@PathParam("diceid") diceid: String, @QueryParam("scale") scale: Int? = 7, @QueryParam("clearAfter") clearAfter: Long? = -1): TemplateInstance {
        return Templates.overlay(diceid, scale ?: 7, clearAfter ?: -1)
    }

    @GET
    @Path("/results")
    @Produces(MediaType.TEXT_HTML)
    fun results(@PathParam("diceid") room: String, @QueryParam("name") name: String?): TemplateInstance {
        return Templates.results(room, name ?: "all")
    }
}
