Apply the handler if the prefix matches.
166462
def _maybe_handle(self, prefix, handler, path, params, data=None):
    """"""
    if path.startswith(prefix):
      relpath = path[len(prefix):]
      if data:
        handler(relpath, params, data)
      else:
        handler(relpath, params)
      return True
    else:
      return False
438798
public RouteMatcher patch(String pattern, Handler<HttpServerRequest> handler) {
		addPattern(pattern, handler, patchBindings);
		return this;
	}
54817
protected function applyPrefix()
    {
        if (is_callable($this->prefix)) {
            $prefix = call_user_func($this->prefix, $this);
        } else {
            $prefix = $this->prefix;
        }
        if ($prefix && strpos($this->_slug, $prefix) === false) {
            $this->_slug = $prefix . $this->_slug;
        }
    }
763351
function tryWrapper(handler) {
    for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
        args[_key - 1] = arguments[_key];
    }

    try {
        handler.apply(undefined, args);
    } catch (err) {
        console.error("handler received an error: " + err.message + ", " + JSON.stringify(err));
    }
}
1154311
def on(self, handler):
        """"""
        if not hasattr(handler, '__call__'):
            raise TypeError('handler is not a callable object.')
        self.handlers.add(handler)
82216
function prefix (a, b) {
  if(a.length > b.length) return false
  var l = a.length - 1
  var lastA = a[l]
  var lastB = b[l]

  if(typeof lastA !== typeof lastB)
    return false

  if('string' == typeof lastA
    && 0 != lastB.indexOf(lastA))
      return false
  
  //handle cas where there is no key prefix
  //(a hook on an entire sublevel)
  if(a.length == 1 && isArrayLike(lastA)) l ++
  
  while(l--) {
    if(compare(a[l], b[l])) return false
  }
  return true
}
1326612
def trigger?(message)
      if @prefix.is_a? String
        standard_prefix_trigger(message.content, @prefix)
      elsif @prefix.is_a? Array
        @prefix.map { |e| standard_prefix_trigger(message.content, e) }.reduce { |m, e| m || e }
      elsif @prefix.respond_to? :call
        @prefix.call(message)
      end
    end
183824
def make_prefix(api_version, manipulator, auth_type):
    """"""
    prefix = "%s_%s" % (api_version, manipulator)
    if (auth_type and auth_type != 'none'):
        prefix += '_' + auth_type
    return prefix
576233
def prefixed(self, prefix):
        """"""
        old_prefix = self._prefix
        if old_prefix is None:
            self._prefix = prefix
        else:
            self._prefix = "{}{}".format(old_prefix, prefix)
        yield self
        self._prefix = old_prefix
822221
def on_excepthandler(self, node):  # ('type', 'name', 'body')
        """"""
        return (self.run(node.type), node.name, node.body)
494404
protected void ensurePrefixAndSchemaFitToegether(String prefix, String schema) {
    if (schema == null) {
      return;
    } else if (prefix == null || (prefix != null && !prefix.startsWith(schema + "."))) {
      throw new ProcessEngineException("When setting a schema the prefix has to be schema + '.'. Received schema: " + schema + " prefix: " + prefix);
    }
  }
441952
async def handler(event):
    """"""
    query = urllib.parse.quote(event.pattern_match.group(1))
    await asyncio.wait([
        event.delete(),
        event.respond(SEARCH.format(query), reply_to=event.reply_to_msg_id)
    ])
67859
public static void patch(@NotNull String path, @NotNull Handler handler) {
        staticInstance().patch(prefixPath(path), handler);
    }
524046
private static void initPrefixHandlers()
    {
        PrefixHandlerConfig[] prefixHandlers = ConfigUtil.getConfig().getPrefixHandlers();
        if ( prefixHandlers == null )
        {
            return;
        }
        for ( int i = 0; i < prefixHandlers.length; i++ )
        {
            try
            {
                Class prefixClass = Class.forName( prefixHandlers[i].getHandlerClass() );
                String name = prefixHandlers[i].getName();
                if ( name == null || name.equals( "" ) )
                {
                    _log.warn( "The name for the prefix handler '" + prefixHandlers[i].getHandlerClass()
                            + "' must not be null" );
                    continue;
                }
                Object o = prefixClass.newInstance();
                if ( !( o instanceof RequestParameterHandler ) )
                {
                    _log.warn( "The class '" + prefixHandlers[i].getHandlerClass()
                            + "' must be an instance of RequestParameterHandler" );
                    continue;
                }
                ProcessPopulate.registerPrefixHandler( name, ( RequestParameterHandler ) o );
            }
            catch ( ClassNotFoundException e )
            {
                _log.warn( "Class '" + prefixHandlers[i].getHandlerClass() + "' not found", e );
            }
            catch ( IllegalAccessException e )
            {
                _log.warn( "Illegal access on Class '" + prefixHandlers[i].getHandlerClass() + "'", e );

            }
            catch ( InstantiationException e )
            {
                _log.warn( "InstantiationException on Class '" + prefixHandlers[i].getHandlerClass() + "'",
                        e.getCause() );
            }
        }
    }
377847
def get_handler_class(ext):
    """"""

    if ext in _extensions_map:
        format = _extensions_map[ext]
    else:
        raise ValueError("Unknown format for %s extension." % ext)

    if format in _handler_map:
        hc = _handler_map[format]
        return hc
    else:
        matches = difflib.get_close_matches(format, _handler_map.keys())
        raise ValueError("Unknown Handler for format %s, close matches: %s"
                         % (format, str(matches)))
1141813
def prefix(self, prefix):
        
        original_prefix = self._prefix
        self._prefix += prefix
        yield self
        self._prefix = original_prefix
403035
function prefixLength(text, prefix) {
  const exp = new RegExp(`^${prefix.pattern}`);
  return matchLength(text, exp);
}