using Microsoft.AspNetCore.Mvc; using SkinsApi.Interfaces.Services; namespace SkinsApi.Controllers.v1 { [Route("/api/v1/skin/")] [ApiController] public class SkinsController(ISkinService skinService) : ControllerBase { /// /// Get user`s skin /// /// nickname or UUID /// Full skin [HttpGet("{user}")] [ProducesResponseType(200)] [Produces("image/png")] public async Task GetSkinByUser(string user, [FromQuery(Name = "w")] int width = 64) { return File((await skinService.GetSkinStreamAsync(user)).GetAllSkin(width), "image/png"); } /// /// Get user`s face /// /// nickname or UUID /// Face [HttpGet("{user}/face")] [ProducesResponseType(200)] [Produces("image/png")] public async Task GetSkinFaceByUser(string user, [FromQuery(Name = "w")] int width = 8) { return File((await skinService.GetSkinStreamAsync(user)).GetFace(width), "image/png"); } /// /// Get user`s front /// /// nickname or UUID /// Face [HttpGet("{user}/front")] [ProducesResponseType(200)] [Produces("image/png")] public async Task GetSkinFrontByUser(string user, [FromQuery(Name = "w")] int width = 128) { try { return File((await skinService.GetSkinStreamAsync(user)).GetBody(width), "image/png"); } catch (Exception ex) { return NotFound(); } } } }