function route($pattern,$handler,$ttl=0,$kbps=0) {
		$types=['sync','ajax','cli'];
		$alias=null;
		if (is_array($pattern)) {
			foreach ($pattern as $item)
				$this->route($item,$handler,$ttl,$kbps);
			return;
		}
		preg_match('/([\|\w]+)\h+(?:(?:@?(.+?)\h*:\h*)?(@(\w+)|[^\h]+))'.
			'(?:\h+\[('.implode('|',$types).')\])?/u',$pattern,$parts);
		if (isset($parts[2]) && $parts[2])
			$this->hive['ALIASES'][$alias=$parts[2]]=$parts[3];
		elseif (!empty($parts[4])) {
			if (empty($this->hive['ALIASES'][$parts[4]]))
				user_error(sprintf(self::E_Named,$parts[4]),E_USER_ERROR);
			$parts[3]=$this->hive['ALIASES'][$alias=$parts[4]];
		}
		if (empty($parts[3]))
			user_error(sprintf(self::E_Pattern,$pattern),E_USER_ERROR);
		$type=empty($parts[5])?0:constant('self::REQ_'.strtoupper($parts[5]));
		foreach ($this->split($parts[1]) as $verb) {
			if (!preg_match('/'.self::VERBS.'/',$verb))
				$this->error(501,$verb.' '.$this->hive['URI']);
			$this->hive['ROUTES'][$parts[3]][$type][strtoupper($verb)]=
				[$handler,$ttl,$kbps,$alias];
		}
	}
function route($pattern,$handler,$ttl=0,$kbps=0) {
		$types=['sync','ajax','cli'];
		$alias=null;
		if (is_array($pattern)) {
			foreach ($pattern as $item)
				$this->route($item,$handler,$ttl,$kbps);
			return;
		}
		preg_match('/([\|\w]+)\h+(?:(?:@?(.+?)\h*:\h*)?(@(\w+)|[^\h]+))'.
			'(?:\h+\[('.implode('|',$types).')\])?/u',$pattern,$parts);
		if (isset($parts[2]) && $parts[2])
			$this->hive['ALIASES'][$alias=$parts[2]]=$parts[3];
		elseif (!empty($parts[4])) {
			if (empty($this->hive['ALIASES'][$parts[4]]))
				user_error(sprintf(self::E_Named,$parts[4]),E_USER_ERROR);
			$parts[3]=$this->hive['ALIASES'][$alias=$parts[4]];
		}
		if (empty($parts[3]))
			user_error(sprintf(self::E_Pattern,$pattern),E_USER_ERROR);
		$type=empty($parts[5])?0:constant('self::REQ_'.strtoupper($parts[5]));
		foreach ($this->split($parts[1]) as $verb) {
			if (!preg_match('/'.self::VERBS.'/',$verb))
				$this->error(501,$verb.' '.$this->hive['URI']);
			$this->hive['ROUTES'][$parts[3]][$type][strtoupper($verb)]=
				[$handler,$ttl,$kbps,$alias];
		}
	}
function route ( $ pattern , $ handler , $ ttl = 0 , $ kbps = 0 ) { $ types = [ 'sync' , 'ajax' , 'cli' ] ; $ alias = null ; if ( is_array ( $ pattern ) ) { foreach ( $ pattern as $ item ) $ this -> route ( $ item , $ handler , $ ttl , $ kbps ) ; return ; } preg_match ( '/([\|\w]+)\h+(?:(?:@?(.+?)\h*:\h*)?(@(\w+)|[^\h]+))' . '(?:\h+\[(' . implode ( '|' , $ types ) . ')\])?/u' , $ pattern , $ parts ) ; if ( isset ( $ parts [ 2 ] ) && $ parts [ 2 ] ) $ this -> hive [ 'ALIASES' ] [ $ alias = $ parts [ 2 ] ] = $ parts [ 3 ] ; elseif ( ! empty ( $ parts [ 4 ] ) ) { if ( empty ( $ this -> hive [ 'ALIASES' ] [ $ parts [ 4 ] ] ) ) user_error ( sprintf ( self :: E_Named , $ parts [ 4 ] ) , E_USER_ERROR ) ; $ parts [ 3 ] = $ this -> hive [ 'ALIASES' ] [ $ alias = $ parts [ 4 ] ] ; } if ( empty ( $ parts [ 3 ] ) ) user_error ( sprintf ( self :: E_Pattern , $ pattern ) , E_USER_ERROR ) ; $ type = empty ( $ parts [ 5 ] ) ? 0 : constant ( 'self::REQ_' . strtoupper ( $ parts [ 5 ] ) ) ; foreach ( $ this -> split ( $ parts [ 1 ] ) as $ verb ) { if ( ! preg_match ( '/' . self :: VERBS . '/' , $ verb ) ) $ this -> error ( 501 , $ verb . ' ' . $ this -> hive [ 'URI' ] ) ; $ this -> hive [ 'ROUTES' ] [ $ parts [ 3 ] ] [ $ type ] [ strtoupper ( $ verb ) ] = [ $ handler , $ ttl , $ kbps , $ alias ] ; } }
Bind handler to route pattern
@return NULL
@param $pattern string|array
@param $handler callback
@param $ttl int
@param $kbps int
Bind handler to route pattern