forked from JSONAPIdotNET/JSONAPI.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartup.cs
More file actions
38 lines (32 loc) · 1.14 KB
/
Copy pathStartup.cs
File metadata and controls
38 lines (32 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System.Web.Http;
using JSONAPI.Core;
using JSONAPI.EntityFramework;
using JSONAPI.TodoMVC.API.Models;
using Owin;
using PluralizationService = JSONAPI.Core.PluralizationService;
namespace JSONAPI.TodoMVC.API
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
var httpConfig = GetWebApiConfiguration();
app.UseWebApi(httpConfig);
}
private static HttpConfiguration GetWebApiConfiguration()
{
var pluralizationService = new PluralizationService();
pluralizationService.AddMapping("todo", "todos");
var modelManager = new ModelManager(pluralizationService);
modelManager.RegisterResourceType(typeof (Todo));
var httpConfig = new HttpConfiguration();
// Configure JSON API
new JsonApiConfiguration(modelManager)
.UseEntityFramework()
.Apply(httpConfig);
// Web API routes
httpConfig.Routes.MapHttpRoute("DefaultApi", "{controller}/{id}", new { id = RouteParameter.Optional });
return httpConfig;
}
}
}