mirror of
https://github.com/yawaflua/SkinsApi.git
synced 2025-12-09 03:49:32 +02:00
Add project files.
This commit is contained in:
60
Controllers/v1/SkinsController.cs
Normal file
60
Controllers/v1/SkinsController.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.RateLimiting;
|
||||
using SkinsApi.Interfaces.Services;
|
||||
|
||||
namespace SkinsApi.Controllers.v1
|
||||
{
|
||||
[Route("/api/v1/skin/")]
|
||||
[ApiController]
|
||||
|
||||
public class SkinsController (ISkinService skinService): ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Get user`s skin
|
||||
/// </summary>
|
||||
/// <param name="user">nickname or UUID</param>
|
||||
/// <returns>Full skin</returns>
|
||||
[HttpGet("{user}")]
|
||||
[ProducesResponseType(200)]
|
||||
[Produces("image/png")]
|
||||
public async Task<IActionResult> GetSkinByUser(string user, [FromQuery(Name = "w")] int width = 64)
|
||||
{
|
||||
|
||||
return File((await skinService.GetSkinStreamAsync(user)).GetAllSkin(width), "image/png");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get user`s face
|
||||
/// </summary>
|
||||
/// <param name="user">nickname or UUID</param>
|
||||
/// <returns>Face</returns>
|
||||
[HttpGet("{user}/face")]
|
||||
[ProducesResponseType(200)]
|
||||
[Produces("image/png")]
|
||||
public async Task<IActionResult> GetSkinFaceByUser(string user, [FromQuery(Name = "w")] int width = 8)
|
||||
{
|
||||
|
||||
return File((await skinService.GetSkinStreamAsync(user)).GetFace(width), "image/png");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get user`s front
|
||||
/// </summary>
|
||||
/// <param name="user">nickname or UUID</param>
|
||||
/// <returns>Face</returns>
|
||||
[HttpGet("{user}/front")]
|
||||
[ProducesResponseType(200)]
|
||||
[Produces("image/png")]
|
||||
public async Task<IActionResult> 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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user