Getting client version info from core layer #103.

pull/122/head
Halil İbrahim Kalkan 7 years ago
parent d655a65d5e
commit e2496b87cc

@ -0,0 +1,19 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.ApiVersioning;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.AspNetCore.Mvc.Versioning
{
public class HttpContextRequestedApiVersion : IRequestedApiVersion, ITransientDependency
{
public string Current => _httpContextAccessor.HttpContext?.GetRequestedApiVersion().ToString();
private readonly IHttpContextAccessor _httpContextAccessor;
public HttpContextRequestedApiVersion(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
}
}
}

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.ApiVersioning;
using Volo.Abp.Application.Services;
using Volo.Abp.AspNetCore.Mvc;
@ -10,16 +11,23 @@ namespace Volo.Abp.Identity
[Route("api/v{api-version:apiVersion}/identity/fixture")]
public class FixtureController : AbpController, IRemoteService
{
private readonly IRequestedApiVersion _requestedApiVersion;
public FixtureController(IRequestedApiVersion requestedApiVersion)
{
_requestedApiVersion = requestedApiVersion;
}
[HttpGet, MapToApiVersion("2.0")]
public int Get()
public string Get()
{
return 41;
return 41 + " - " + _requestedApiVersion.Current;
}
[HttpGet, MapToApiVersion("3.0")]
public int Get3()
public string Get3()
{
return 42;
return 42 + " - " + _requestedApiVersion.Current;
}
[HttpPost]

@ -0,0 +1,7 @@
namespace Volo.Abp.ApiVersioning
{
public interface IRequestedApiVersion
{
string Current { get; }
}
}
Loading…
Cancel
Save