1
0
mirror of https://github.com/bitwarden/server.git synced 2025-02-16 01:51:21 +01:00

version api and re-route other misc apis

This commit is contained in:
Kyle Spearrin 2017-08-19 07:59:19 -04:00
parent ee0b212d3e
commit bac8ef9013
3 changed files with 48 additions and 31 deletions

View File

@ -1,31 +0,0 @@
using System;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
using System.Reflection;
namespace Bit.Api.Controllers
{
[Route("alive")]
public class AliveController : Controller
{
[HttpGet("")]
public DateTime Get()
{
return DateTime.UtcNow;
}
[HttpGet("claims")]
public IActionResult Claims()
{
return new JsonResult(User?.Claims?.Select(c => new { c.Type, c.Value }));
}
[HttpGet("version")]
public IActionResult Version()
{
var version = Assembly.GetEntryAssembly()
.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
return new JsonResult(version);
}
}
}

View File

@ -0,0 +1,28 @@
using System;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
using Bit.Core.Models.Api;
namespace Bit.Api.Controllers
{
public class MiscController : Controller
{
[HttpGet("~/alive")]
public DateTime Get()
{
return DateTime.UtcNow;
}
[HttpGet("~/claims")]
public IActionResult Claims()
{
return new JsonResult(User?.Claims?.Select(c => new { c.Type, c.Value }));
}
[HttpGet("~/version")]
public VersionResponseModel Version()
{
return new VersionResponseModel();
}
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Reflection;
namespace Bit.Core.Models.Api
{
public class VersionResponseModel : ResponseModel
{
public VersionResponseModel()
: base("version")
{
Version = Assembly.GetEntryAssembly()
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
.InformationalVersion;
VersionInt = Convert.ToInt32(Version.Replace(".", string.Empty));
}
public string Version { get; set; }
public int VersionInt { get; set; }
}
}