Skip to content

Commit

Permalink
Added HomeController and VersionController. (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
Utar94 authored Oct 18, 2023
1 parent 23988ef commit e127b96
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
18 changes: 18 additions & 0 deletions backend/src/Logitar.Wishes.Web/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Microsoft.AspNetCore.Mvc;

namespace Logitar.Wishes.Web.Controllers;

[ApiExplorerSettings(IgnoreApi = true)]
[Route("")]
public class HomeController : ControllerBase
{
private readonly Version _version;

public HomeController(IConfiguration configuration)
{
_version = new Version(configuration.GetValue<string>("Version") ?? string.Empty);
}

[HttpGet]
public ActionResult Index() => Ok($"Wishes API v{_version}");
}
19 changes: 19 additions & 0 deletions backend/src/Logitar.Wishes.Web/Controllers/VersionController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Logitar.Wishes.Web.Models.Version;
using Microsoft.AspNetCore.Mvc;

namespace Logitar.Wishes.Web.Controllers;

[ApiController]
[Route("version")]
public class VersionController : ControllerBase
{
private readonly Version _version;

public VersionController(IConfiguration configuration)
{
_version = new Version(configuration.GetValue<string>("Version") ?? string.Empty);
}

[HttpGet]
public ActionResult<ApplicationVersion> Get() => Ok(new ApplicationVersion(_version));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Logitar.Wishes.Web.Models.Version;

public record ApplicationVersion
{
public string Version { get; }

public ApplicationVersion(System.Version version)
{
Version = version.ToString();
}
}
2 changes: 1 addition & 1 deletion backend/src/Logitar.Wishes/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"Microsoft.AspNetCore": "Warning"
}
},
"Version": "0.1.1"
"Version": "0.1.2"
}

0 comments on commit e127b96

Please sign in to comment.