Skip to content

Commit

Permalink
removing custom before handler in favour of ootb lifecycle hooks on r…
Browse files Browse the repository at this point in the history
…outes

#12
  • Loading branch information
kristofsajdak committed Dec 9, 2015
1 parent f9f0e39 commit 5bf2317
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
12 changes: 0 additions & 12 deletions lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,6 @@ exports.register = function (server, opts, next) {
}
})

server.ext('onPreHandler', function (request, reply) {
var routeSettingsForHarvester = request.route.settings.plugins.harvester
if (routeSettingsForHarvester) {
const before = routeSettingsForHarvester.before
if (before) {
before(request, reply)
return;
}
}
reply.continue()
})

server.ext('onPreResponse', (request, reply) => {
function globallySetContentTypeJsonApi(request) {
request.response = request.response || {}
Expand Down
8 changes: 4 additions & 4 deletions test/onbefore.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ const schema = {
brands: {
type: 'brands',
attributes: {},
config: {
plugins: {
harvester: {
before(req, reply) {
config: {
ext: {
onPreHandler: {
method(req, reply) {
let code = 404;
if (req.method === 'get') {
if (req.params.id) {
Expand Down

0 comments on commit 5bf2317

Please sign in to comment.