Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/Helldivers-2-API/Controllers/V1/SpaceStationController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Helldivers.Core.Contracts.Collections;
using Helldivers.Models.V1;
using Microsoft.AspNetCore.Mvc;

namespace Helldivers.API.Controllers.V1;

/// <summary>
/// Contains API endpoints for <see cref="SpaceStation" />.
/// </summary>
public static class SpaceStationController
{
/// <summary>
/// Fetches a list of all available <see cref="SpaceStation" /> information available.
/// </summary>
[ProducesResponseType<List<SpaceStation>>(StatusCodes.Status200OK)]
public static async Task<IResult> Index(HttpContext context, IStore<SpaceStation, int> store)
{
var stations = await store.AllAsync(context.RequestAborted);

return Results.Ok(stations);
}

/// <summary>
/// Fetches a specific <see cref="SpaceStation" /> identified by <paramref name="index" />.
/// </summary>
public static async Task<IResult> Show(HttpContext context, IStore<SpaceStation, int> store, [FromRoute] int index)
{
var station = await store.GetAsync(index, context.RequestAborted);

if (station is null)
return Results.NotFound();

return Results.Ok(station);
}
}
3 changes: 3 additions & 0 deletions src/Helldivers-2-API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@
v1.MapGet("/planets/{index:int}", PlanetController.Show);
v1.MapGet("/planet-events", PlanetController.WithEvents);

v1.MapGet("/space-stations", SpaceStationController.Index);
v1.MapGet("/space/stations/{index:int}", SpaceStationController.Show);

v1.MapGet("/steam", SteamController.Index);
v1.MapGet("/steam/{gid}", SteamController.Show);

Expand Down