Skip to content

Commit 9b7292d

Browse files
committed
rename IndexController, add /version endpoint, and make it visible to swagger
1 parent da3bfc1 commit 9b7292d

2 files changed

Lines changed: 36 additions & 22 deletions

File tree

src/Server/Controllers/IndexController.cs

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using Gommon;
2+
using Microsoft.AspNetCore.Mvc;
3+
using Ryujinx.Systems.Update.Server.Helpers;
4+
5+
namespace Ryujinx.Systems.Update.Server.Controllers;
6+
7+
[Route("/")]
8+
[ApiController]
9+
public class InfoController : ControllerBase
10+
{
11+
[HttpGet]
12+
[ApiExplorerSettings(IgnoreApi = true)]
13+
public ActionResult Index()
14+
=> Redirect("https://github.com/Ryubing/UpdateServer/");
15+
16+
[HttpGet("docs"), HttpGet("info"), HttpGet("help")]
17+
[EndpointDescription("Redirects the requestor to the /swagger endpoint.")]
18+
public ActionResult Help()
19+
{
20+
return CommandLineState.Swagger
21+
? Redirect("/swagger")
22+
: Index();
23+
}
24+
25+
public static readonly string ServerVersion = typeof(Program).Assembly.GetName().Version!.ToString()[..^2];
26+
public const string ReleaseUrlFormat = "https://github.com/Ryubing/UpdateServer/releases/tag/{0}";
27+
28+
[HttpGet("version")]
29+
[EndpointDescription("Redirects to or shows the requestor the current UpdateServer GitHub release URL.")]
30+
public ActionResult Version([FromQuery] bool redirect = true)
31+
{
32+
return redirect
33+
? Redirect(ReleaseUrlFormat.Format(ServerVersion))
34+
: Ok(ReleaseUrlFormat.Format(ServerVersion));
35+
}
36+
}

0 commit comments

Comments
 (0)