API Endpoints for stevedunn/oglr
The stevedunn/oglr
codebase defines a variety of routes that facilitate interaction with the underlying application logic. These routes are implemented within the Startup.cs
file and corresponding controllers, primarily using ASP.NET Core’s routing mechanisms. Below are the primary routes defined in the codebase along with examples to illustrate their usage.
Route Definitions
1. Root Route
The application defines a root route which serves as the entry point.
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", async context =>
{
await context.Response.WriteAsync("Welcome to OGLR!");
});
});
Usage: This route can be accessed via a simple GET request to the base URL, effectively rendering a welcome message.
2. Game Routes
The route for accessing game-related endpoints is implemented as follows:
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "games",
pattern: "api/games/{id?}",
defaults: new { controller = "Games", action = "Get" });
});
Usage: This route allows retrieval of games by ID. A GET request to api/games/{id}
retrieves details of a specific game, while a GET request to api/games/
returns a list of all games.
3. Player Routes
Routes for player management operate under a similar structure:
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "players",
pattern: "api/players/{playerId}",
defaults: new { controller = "Players", action = "GetPlayer" });
});
Usage: This endpoint retrieves player information based on playerId
. A GET request to api/players/{playerId}
returns the details of the specified player.
4. Leaderboard Routes
An additional set of routes is dedicated to accessing leaderboard data:
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "leaderboard",
pattern: "api/leaderboard",
defaults: new { controller = "Leaderboard", action = "GetLeaderboard" });
});
Usage: This route can be accessed to retrieve the current leaderboard information. A GET request to api/leaderboard
results in a JSON representation of the leaderboard.
5. Authentication Routes
Authentication functionalities are also encapsulated within their own routing configuration:
app.UseEndpoints(endpoints => { endpoints.MapPost("api/auth/login", async context => { // Handle login logic });
endpoints.MapPost("api/auth/register", async context => { // Handle registration logic }); });
Usage: The login functionality is accessed via a POST request to api/auth/login
, while user registration utilizes a POST request to api/auth/register
.
6. Miscellaneous Routes
Various utility routes can be found throughout the application for specific functionalities:
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("api/status", async context =>
{
await context.Response.WriteAsync("API is running.");
});
});
Usage: A simple health check can be performed by sending a GET request to api/status
, returning the service status.
Source Information
The routes defined in the stevedunn/oglr
codebase primarily reside within the Startup.cs
file and respective controller classes, ensuring standard routing practices within an ASP.NET Core application context.