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 22, 2015
1 parent
a5ebe79
commit 6961d7f
Showing
2 changed files
with
37 additions
and
18 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,29 @@ | ||
// 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); | ||
} | ||
} | ||
}); | ||
|
||
return next(); | ||
}; | ||
|
||
// Plugin metadata | ||
exports.register.attributes = { | ||
name: 'version' | ||
}; |