Created
November 9, 2019 14:14
-
-
Save AbubakarSiddiq/0e9269216de9ebbfd9225ee41a3cee19 to your computer and use it in GitHub Desktop.
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Mvc; | |
namespace AspNetCoreVersioning.Controllers | |
{ | |
[ApiVersion("1.0")] | |
[Route("api/v{v:apiVersion}/Values")] | |
[ApiController] | |
public class ValuesV1Controller : ControllerBase | |
{ | |
// GET: api/<controller> | |
[HttpGet] | |
public IEnumerable<string> Get() | |
{ | |
return new string[] { "value one from api version", "One"}; | |
} | |
} | |
[ApiVersion("2.0")] | |
[Route("api/v{v:apiVersion}/Values")] | |
[ApiController] | |
public class ValuesV2Controller : ControllerBase | |
{ | |
// GET: api/<controller> | |
[HttpGet] | |
public IEnumerable<string> Get() | |
{ | |
return new string[] { "value two from the api version", "two" }; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment