Created
January 14, 2014 16:20
-
-
Save rfaisal/8421007 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
[EnableCors(origins: "*", headers: "*", methods: "*")] | |
// [Authorize] | |
public class ValuesController : ApiController | |
{ | |
private static List<string> values = new List<string>(); | |
// GET api/values | |
public IEnumerable<string> Get() | |
{ | |
return values; | |
} | |
// GET api/values/?index=3 | |
public string Get(int index) | |
{ | |
return values.ElementAtOrDefault(index); | |
} | |
// POST api/values | |
public void Post([FromBody]string value) | |
{ | |
values.Add(value); | |
} | |
// PUT api/values/5 | |
public void Put(int index, [FromBody]string value) | |
{ | |
if (values.Count > index) | |
values[index] = value; | |
else | |
Post(value); | |
} | |
// DELETE api/values/5 | |
public void Delete(int index) | |
{ | |
if (values.Count > index) | |
values.RemoveAt(index); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment