Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. function versioning(paths) {
  2. let versions = Object.keys(paths);
  3. let defaultPath = versions[0];
  4.  
  5. return function(request, reply) {
  6. if (versions.contains(request.headers['accept-header'])) {
  7. return paths[request.headers['accept-header']](request, reply);
  8. }
  9. return paths[defaultPath](request, reply);
  10. }
  11. }
  12.  
  13. server.route({
  14. method: 'GET',
  15. path: '/test',
  16. handler: versioning({
  17. '1.0': Version1,
  18. '2.0': Vervsion2
  19. })
  20. });
  21.  
  22. function Version1(request, reply) {
  23. }
  24.  
  25. function Version2(request, reply) {
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement