Guest User

Untitled

a guest
Jul 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. namespace NancyConNegDemo
  2. {
  3. using Extensions;
  4. using Models;
  5. using Nancy;
  6.  
  7. public class ConNegModule : NancyModule
  8. {
  9. public ConNegModule() : base("/conneg")
  10. {
  11. Get["/user/{id}"] = x =>
  12. {
  13. var model = database.GetUserById(x.id);
  14.  
  15. return I.RespondTo(ContentType.Html).WithView("UserView")
  16. .RespondTo(ContentType.Json)
  17. .RespondTo(ContentType.Xml)
  18. .UsingModel(model)
  19. .CacheFor(7).Days
  20. .WithETag(hash);
  21. };
  22.  
  23. Get["/widget/{id}"] = x =>
  24. {
  25. var model = database.GetWidgetById(x.id);
  26.  
  27. return I.RespondToAll()
  28. .Except(ContentType.Html)
  29. .UsingModel(model);
  30. };
  31. }
  32. }
  33. }
Add Comment
Please, Sign In to add comment