diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-02-13 17:05:59 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-13 17:05:59 -0600 |
| commit | 034eff1ad47a4ac976237d4e13c596ba1404cd2f (patch) | |
| tree | 8d9650d86237fe511a600ae58016b1ff3de3a389 /src/slskd/API/Controllers/PublicChatController.cs | |
| parent | aec49da74c08865353faae4d97fb4e405ae970e5 (diff) | |
| parent | 1744c9b2ded05a8a83874864957229a3235fb546 (diff) | |
| download | slskd-034eff1ad47a4ac976237d4e13c596ba1404cd2f.tar.gz | |
Merge pull request #40 from slskd/housekeeping
Tidy up
Diffstat (limited to 'src/slskd/API/Controllers/PublicChatController.cs')
| -rw-r--r-- | src/slskd/API/Controllers/PublicChatController.cs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/slskd/API/Controllers/PublicChatController.cs b/src/slskd/API/Controllers/PublicChatController.cs new file mode 100644 index 00000000..63a91ff4 --- /dev/null +++ b/src/slskd/API/Controllers/PublicChatController.cs @@ -0,0 +1,50 @@ +namespace slskd.API.Controllers +{ + using Microsoft.AspNetCore.Authorization; + using Microsoft.AspNetCore.Http; + using Microsoft.AspNetCore.Mvc; + using Soulseek; + using System.Threading.Tasks; + + /// <summary> + /// Server + /// </summary> + [Route("api/v{version:apiVersion}/[controller]")] + [ApiVersion("0")] + [ApiController] + [Produces("application/json")] + [Consumes("application/json")] + public class PublicChatController : ControllerBase + { + private ISoulseekClient Client { get; } + + public PublicChatController(ISoulseekClient client) + { + Client = client; + } + + /// <summary> + /// Starts public chat. + /// </summary> + /// <returns></returns> + [HttpPost] + [Authorize] + public async Task<IActionResult> Start() + { + await Client.StartPublicChatAsync(); + return StatusCode(StatusCodes.Status201Created); + } + + /// <summary> + /// Stops public chat. + /// </summary> + /// <returns></returns> + [HttpDelete] + [Authorize] + public async Task<IActionResult> Stop() + { + await Client.StopPublicChatAsync(); + return StatusCode(StatusCodes.Status204NoContent); + } + } +} |
