feat(api): redirect root to API docs, return 410 gone for v1 routes

This commit is contained in:
spiral 2022-06-10 18:47:25 -04:00
parent 1b5a90f612
commit 97d8863481
No known key found for this signature in database
GPG Key ID: 244A11E4B0BCF40E

View File

@ -133,7 +133,15 @@ public class Startup
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints => endpoints.MapControllers());
app.UseEndpoints(endpoints =>
{
// register base / legacy routes
endpoints.MapMethods("", new string[] { }, (context) => { context.Response.Redirect("https://pluralkit.me/api"); return Task.CompletedTask;});
endpoints.MapMethods("v1/{*_}", new string[] { }, (context) => context.Response.WriteJSON(410, "{\"message\":\"Unsupported API version\",\"code\":0}"));
// register controllers
endpoints.MapControllers();
});
// metrics
app.UseMetricsAllMiddleware();