Skip to content

Commit

Permalink
Updated with product versions
Browse files Browse the repository at this point in the history
  • Loading branch information
OsirisTerje committed Feb 22, 2022
1 parent d4eb30e commit 84c153c
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 4 deletions.
32 changes: 31 additions & 1 deletion WrapThat.Version/InfoController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Reflection;
using System.Diagnostics;
using System.Reflection;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

Expand All @@ -18,6 +19,17 @@ public ActionResult<string> Version()
return Ok(version?.ToSemver());
}

[HttpGet]
[Route("productversion")]
public ActionResult<string> ProductVersion()
{
var assembly = Assembly.GetEntryAssembly();
var fileversioninfo = FileVersionInfo.GetVersionInfo(assembly.Location);
return Ok(fileversioninfo.ProductVersion);
}



[HttpGet]
[AllowAnonymous]
public ActionResult<string> Info()
Expand All @@ -27,6 +39,24 @@ public ActionResult<string> Info()
return Ok(shields);
}

[HttpGet]
[AllowAnonymous]
[Route("shields/version")]
public ActionResult<string> InfoShields() => Info();


[HttpGet]
[Route("shields/productversion")]
public ActionResult<string> ProductVersionShields()
{
var assembly= Assembly.GetEntryAssembly();
var fileversioninfo = FileVersionInfo.GetVersionInfo(assembly.Location);
var shields = new ShieldsIo("Version", fileversioninfo.ProductVersion);
return Ok(shields);
}



[HttpGet]
[Route("status")]
public ActionResult<string> Status()
Expand Down
2 changes: 1 addition & 1 deletion WrapThat.Version/WrapThat.Version.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>WrapThat.Version</PackageId>
<Version>0.9.3</Version>
<Version>0.9.4</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
32 changes: 30 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Install from nuget

## Usage

Add this package to your main ASP.Net project, and it will add an Info endpoint with three methods, giving you the version of the main assembly in semver format.
Add this package to your main ASP.Net project, and it will add an Info endpoint with five methods, giving you the version of the main assembly in semver format.

### Get version as a string

Expand All @@ -17,10 +17,20 @@ returns
1.2.3
```

### Get product version as a string

```cs
Route: /api/info/productversion

returns
1.2.3-rc.1
```


### Get version as a [shields.io](https://shields.io/) structure

```cs
Route: /api/info
Route: /api/info/shields/version

returns shields io structure for use in a [shields endpoint](https://shields.io/endpoint) call.
Expand All @@ -34,6 +44,24 @@ https://img.shields.io/endpoint?url=https://yourwebapi/api/info

And you get a lightgrey shields badge back, with label Version and your version number.


### Get ProductVersion as a [shields.io](https://shields.io/) structure
```cs
Route: /api/info/shields/productversion

returns shields io structure for use in a [shields endpoint](https://shields.io/endpoint) call.
```

You call this using shields like:

```
https://img.shields.io/endpoint?url=https://yourwebapi/api/info/productversion
```

And you get a lightgrey shields badge back, with label Version and your version number.

### Get version as a string authenticated

This is the same as the first method, except that it require authentication, if your API/app is set up for that. The intention is that you can use this to check if the authentication is actually working.
Expand Down

0 comments on commit 84c153c

Please sign in to comment.