Created
August 7, 2013 12:56
-
-
Save hagbarddenstore/6173801 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // Controller | |
| public class ValuesController : ApiController | |
| { | |
| public IEnumerable<string> FindAll() | |
| { | |
| } | |
| public string FindOneById(int id) | |
| { | |
| } | |
| public string FindOneByLicense(string license) | |
| { | |
| } | |
| public void Post([FromBody]string value) | |
| { | |
| } | |
| public void Put(int id, [FromBody]string value) | |
| { | |
| } | |
| public void Delete(int id) | |
| { | |
| } | |
| } | |
| // Route configuration | |
| routes.MapRoute("Values.FindAll", "api/values", new { controller = "Values", action = "FindAll" }, new { httpMethod = new HttpMethodConstraint("GET") }); | |
| routes.MapRoute("Values.Post", "api/values", new { controller = "Values", action = "Post" }, new { httpMethod = new HttpMethodConstraint("POST") }); | |
| routes.MapRoute("Values.FindOneById", "api/values/{id}", new { controller = "Values", action = "FindOneById" }, new { httpMethod = new HttpMethodConstraint("GET"), id = "\\d+" }); | |
| routes.MapRoute("Values.Put", "api/values/{id}", new { controller = "Values", action = "Put" }, new { httpMethod = new HttpMethodConstraint("PUT"), id = "\\d+" }); | |
| routes.MapRoute("Values.Delete", "api/values/{id}", new { controller = "Values", action = "Delete" }, new { httpMethod = new HttpMethodConstraint("DELETE"), id = "\\d+" }); | |
| routes.MapRoute("Values.FindOneByLicense", "api/values/{license}", new { controller = "Values", action = "FindOneByLicense" }, new { httpMethod = new HttpMethodConstraint("GET"), license = "\\w+" }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment