-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* add routing for space station endpoints added in #120 * Fix whitespace formatting --------- Co-authored-by: TheDarkGlobe <[email protected]>
- Loading branch information
1 parent
86336c2
commit 857d396
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/Helldivers-2-API/Controllers/V1/SpaceStationController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters