Info
Version: | 1.0.2 |
Author(s): | Ming Lu |
Last Update: | Wednesday, February 10, 2016 |
.NET Fiddle: | Create the first Fiddle |
Project Url: | https://github.com/MingLu8/Nancy.WebApi |
NuGet Url: | https://www.nuget.org/packages/Nancy.WebApi |
Install
Install-Package Nancy.WebApi
dotnet add package Nancy.WebApi
paket add Nancy.WebApi
Nancy.WebApi Download (Unzip the "nupkg" after downloading)
Dependencies
- Newtonsoft.Json(>= 8.0.2)
- Nancy(>= 1.4.3)
Here is some sample usage:
[RoutePrefix("api/responseMessage")]
public class ResponseMessageModule : ApiController
{
[HttpGet(nameof(WithStatusCode))]
public ResponseMessage<Address> WithStatusCode()
{
var result = new Address {City = "dummie city"};
return new ResponseMessage<Address>(() => new JsonResponse(result, new JsonNetSerializer()).WithStatusCode(HttpStatusCode.NotModified));
}
}
[RoutePrefix("api/userApi")]
public class UserApi : ApiController
{
[HttpGet("/")]
public IEnumerable<User> GetAll()
{
return new List<User> { new User(), new User() };
}
[HttpGet("/{id}")]
public User GetById(int id)
{
return new User();
}
}.