(prefix, opts, handler, avvio, routeHandler)
| 141 | } |
| 142 | |
| 143 | function _setNotFoundHandler (prefix, opts, handler, avvio, routeHandler) { |
| 144 | const context = new Context({ |
| 145 | schema: opts.schema, |
| 146 | handler, |
| 147 | config: opts.config || {}, |
| 148 | server: this |
| 149 | }) |
| 150 | |
| 151 | avvio.once(class="st">'preReady', () => { |
| 152 | const context = this[kFourOhFourContext] |
| 153 | for (const hook of lifecycleHooks) { |
| 154 | const toSet = this[kHooks][hook] |
| 155 | .concat(opts[hook] || []) |
| 156 | .map(h => h.bind(this)) |
| 157 | context[hook] = toSet.length ? toSet : null |
| 158 | } |
| 159 | context.errorHandler = opts.errorHandler |
| 160 | ? buildErrorHandler(this[kErrorHandler], opts.errorHandler) |
| 161 | : this[kErrorHandler] |
| 162 | }) |
| 163 | |
| 164 | if (this[kFourOhFourContext] !== null && prefix === class="st">'/') { |
| 165 | Object.assign(this[kFourOhFourContext], context) class="cm">// Replace the default 404 handler |
| 166 | return |
| 167 | } |
| 168 | |
| 169 | this[kFourOhFourLevelInstance][kFourOhFourContext] = context |
| 170 | |
| 171 | router.all(prefix + (prefix.endsWith(class="st">'/') ? class="st">'*' : class="st">'/*'), routeHandler, context) |
| 172 | router.all(prefix, routeHandler, context) |
| 173 | } |
| 174 | |
| 175 | function fourOhFourFallBack (req, res) { |
| 176 | class="cm">// if this happen, we have a very bad bug |
nothing calls this directly
no test coverage detected