forked from outmoded/university
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[assignment 2] Convert version route to plugin
Closes outmoded#43
- Loading branch information
Myles Borins
committed
Mar 18, 2015
1 parent
a5ebe79
commit b9ddd58
Showing
2 changed files
with
34 additions
and
16 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Declare internals | ||
var internals = { | ||
response: { | ||
version: require('../package.json').version | ||
} | ||
}; | ||
|
||
// Register plugin | ||
exports.register = function (server, options, next) { | ||
server.route({ | ||
method: 'GET', | ||
path: '/version', | ||
config: { | ||
description: 'Returns the version of the server', | ||
handler: function (request, reply) { | ||
|
||
return reply(internals.response); | ||
} | ||
} | ||
}); | ||
next(); | ||
}; | ||
|
||
// Plugin metadata | ||
exports.register.attributes = { | ||
name: 'version' | ||
}; |