Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save drcircuit/0f28765128d270691d179338634f2dab to your computer and use it in GitHub Desktop.

Select an option

Save drcircuit/0f28765128d270691d179338634f2dab to your computer and use it in GitHub Desktop.
[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