Created
May 8, 2018 11:21
-
-
Save drcircuit/0f28765128d270691d179338634f2dab 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
| [Route("api/badbutpossible/[controller]")] | |
| public class StuffController: Controller | |
| { | |
| [HttpGet] | |
| public async Task Get() | |
| { | |
| var jsonString = "{\"foo\":\"bar\", \"index\":12}"; | |
| Response.ContentType = "application/json"; | |
| var buffer = System.Text.Encoding.UTF8.GetBytes(jsonString); | |
| await Response.Body.WriteAsync(buffer, 0, buffer.Length); | |
| } | |
| } | |
| [Route("api/betterbutpainfulforsome/[controller]")] | |
| public class StuffV2Controller : Controller | |
| { | |
| List<Book> articles = new List<Book> { | |
| new Book {Id = Guid.NewGuid().ToString(), Title = "A brief history of time", Author = "Stephen Hawking" }, | |
| new Book {Id = Guid.NewGuid().ToString(), Title = "Ready Player One", Author = "Ernest Cline" }, | |
| new Book {Id = Guid.NewGuid().ToString(), Title = "The Bible", Author = "Undetermined" }, | |
| new Book {Id = Guid.NewGuid().ToString(), Title = "The Book of Shadows", Author = "Unknown" }, | |
| new Book {Id = Guid.NewGuid().ToString(), Title = "Necronomicon", Author = "Beelzebub" }, | |
| }; | |
| [HttpGet] | |
| public IEnumerable<Book> ListArticles() | |
| { | |
| return articles; | |
| } | |
| } | |
| public class Book | |
| { | |
| public string Id { get; set; } | |
| public string Title { get; set; } | |
| public string Author { get; set; } | |
| public string DetailLink { get; set; } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment