Derive Web API templates from ControllerBase (#220)

Addresses #45
This commit is contained in:
Jass Bagga 2018-01-08 15:08:43 -08:00 committed by GitHub
parent c50e9e90f0
commit 8ebe0a2d29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 6 deletions

View File

@ -1,5 +1,6 @@
namespace Company.WebApplication1
open System
open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Hosting
open Microsoft.AspNetCore.Http

View File

@ -1,5 +1,9 @@
namespace Company.WebApplication1
open System
open System.Collections.Generic
open System.Linq
open System.Threading.Tasks
open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Hosting
open Microsoft.AspNetCore.HttpsPolicy

View File

@ -13,7 +13,8 @@ namespace Company.WebApplication1.Controllers
[Authorize]
#endif
[Route("api/[controller]")]
public class ValuesController : Controller
[ApiController]
public class ValuesController : ControllerBase
{
// GET api/values
[HttpGet]
@ -31,7 +32,7 @@ namespace Company.WebApplication1.Controllers
// POST api/values
[HttpPost]
public void Post([FromBody]string value)
public void Post([FromBody] string value)
{
#if (OrganizationalAuth || WindowsAuth)
// For more information on protecting this API from Cross Site Request Forgery (CSRF) attacks, see https://go.microsoft.com/fwlink/?LinkID=717803
@ -40,7 +41,7 @@ namespace Company.WebApplication1.Controllers
// PUT api/values/5
[HttpPut("{id}")]
public void Put(int id, [FromBody]string value)
public void Put(int id, [FromBody] string value)
{
#if (OrganizationalAuth || WindowsAuth)
// For more information on protecting this API from Cross Site Request Forgery (CSRF) attacks, see https://go.microsoft.com/fwlink/?LinkID=717803

View File

@ -7,8 +7,9 @@ open System.Threading.Tasks
open Microsoft.AspNetCore.Mvc
[<Route("api/[controller]")>]
[<ApiController>]
type ValuesController () =
inherit Controller()
inherit ControllerBase()
[<HttpGet>]
member this.Get() =
@ -19,11 +20,11 @@ type ValuesController () =
"value"
[<HttpPost>]
member this.Post([<FromBody>]value:string) =
member this.Post([<FromBody>] value:string) =
()
[<HttpPut("{id}")>]
member this.Put(id:int, [<FromBody>]value:string ) =
member this.Put(id:int, [<FromBody>] value:string ) =
()
[<HttpDelete("{id}")>]

View File

@ -1,5 +1,9 @@
namespace Company.WebApplication1
open System
open System.Collections.Generic
open System.Linq
open System.Threading.Tasks
open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Hosting
open Microsoft.AspNetCore.HttpsPolicy