<NME> route.es
<BEF> // https://coderwall.com/p/y347ug/encodeuri-vs-encodeuricomponent
// https://cdivilly.wordpress.com/2014/03/11/why-trailing-slashes-on-uris-are-important/

const
  unspecified = context =>
    context.status = 501

, identify = uri =>
    uri.split `/`.pop ``
    || undefined

, trailing = uri =>
    uri +=
      /\/$/.test (uri)
      ? `${characters}*`
      : ``

, decode     = decodeURIComponent
, characters = '[()A-Za-z%0-9\\*\\-\\_\\.]'
, tokenizer  = [ /{\w+}/g, `(${characters}+)` ]

, normalize  = uri =>
    RegExp (`^${ trailing (uri).replace ( ... tokenizer ) }$`)

, tokenized = (uri, tokens = uri.match (/[^{]+(?=})/g)) =>
    (params, value, index) =>
      (params [tokens [index]] = decode (value))
        && params

, parameterize = (uri, [ _ , ... params ], context) =>
    context.params = params.reduce (tokenized (uri), {})

      (typeof resource === 'object')
        && allow.includes (method)
        || // 405 Method Not Allowed
           // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405
          context.throw (405,  { headers: { allow } } )

      && parameterize (uri, matched, context)
      && (endpoint = endpoint [method.toLowerCase ()] || endpoint)
        ? await endpoint (context, identify (context.path))
        : await next (context)

<MSG> Fix method not allowed

<DFF> @@ -32,7 +32,7 @@ module.exports = ( uri, resource ) => {
 
       (typeof resource === 'object')
         && allow.includes (method)
-        || // 405 Method Not Allowed
+        || // 406 Method Not Allowed
            // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405
           context.throw (405,  { headers: { allow } } )
 

{'addition_count': 1, 'commit_subject': 'Fix method not allowed', 'deletion_count': 1, 'file_extension': '.es', 'lang': 'es', 'license': 'mit', 'repo_name': 'devpunks/snuggsi'}