パスを変換する
@param  string $path     変換前のパス
@param  mixed  $callback コールバック関数 または 変換ルール文字列
@return [type]           変換後のパス
9849
public function rewrite($path, $callback){
		if( is_null($callback) ){
			// コールバック関数が設定されなかった場合
			return $path;
		}elseif( is_callable($callback) ){
			// コールバック関数が設定された場合
			return call_user_func( $callback, $path );
		}elseif( is_string($callback) ){
			$path_rewrited = $callback;
			$data = array(
				'dirname'=>$this->px->fs()->normalize_path(dirname($path)),
				'filename'=>basename($this->px->fs()->trim_extension($path)),
				'ext'=>strtolower($this->px->fs()->get_extension($path)),
			);
			$path_rewrited = str_replace( '{$dirname}', $data['dirname'], $path_rewrited );
			$path_rewrited = str_replace( '{$filename}', $data['filename'], $path_rewrited );
			$path_rewrited = str_replace( '{$ext}', $data['ext'], $path_rewrited );
			return $path_rewrited;
		}
		return $path;
	}
990252
public function get($path, $callback, $condition = true){
        if (!$this->req_is('get')) return;
        $this->bind($path, $callback, $condition);
    }
880881
public static function options( $route = null, $callback = null ) {
		// Make sure that our parameters are what they say they are
		$args = self::smart_parameters( func_get_args() );

		return self::route( 'OPTIONS', $args[ 'route' ], $args[ 'callback' ] );
	}
36330
public static function options($path, $callback)
    {
        self::instance()->addRoute('OPTIONS', $path, self::callback($callback));
    }
872037
public function post($path, $data, $callback)
    {
        // 解决swoole底层http_build_query failed的问题
        if (empty($data)) {
            $data = '';
        }
        $this->client->post($path, $data, $callback);
    }
190247
public function get(string $path, callable $callback, int $priority = 0)
    {
        return $this->route('get', $path, $callback, $priority);
    }
183981
def callback_path
	      @callback_path ||= begin
	        path = options[:callback_path] if options[:callback_path].is_a?(String)
	        path ||= current_path if options[:callback_path].respond_to?(:call) && options[:callback_path].call(env)
	        path ||= custom_path(:request_path)
	        path ||= Auth::OmniAuth::Path.common_callback_path(name)
	        path
	      end
	    end
642115
public function route($name, $path, callable $callback)
    {
        // Modifying path from colon parameters /show/:id to bracket parameters /show/{id}
        $path = preg_replace("|(:(\w+))|", '{$2}', $path);

        // if the route is anonymous
        if (!$name) {
            $name = "N".uniqid();
        }

        $map = $this["router"]->getMap();
        $route = $map->route($name, $path, $callback);

        return $route;
    }
399
public static function createPresets($path = null, $callback = null) {
        $moufManager = MoufManager::getMoufManager();
        $instances = $moufManager->findInstances('Mouf\\Utils\\Graphics\\MoufImagine\\Controller\\ImagePresetController');
        foreach ($instances as $instanceName) {
            $instance = $moufManager->getInstance($instanceName);
            if ($path && strpos($path, $instance->originalPath) !== false && $instance->createPresetsEnabled === true) {
                $imagePath = substr($path, strlen($instance->originalPath) + 1);
                $instance->image($imagePath);

                if(is_callable($callback)) {
                    $finalPath = ROOT_PATH . $instance->url . DIRECTORY_SEPARATOR . $imagePath;
                    $callback($finalPath);
                }
            }
        }
    }
666415
public static function put($path, $callback)
    {
        self::instance()->addRoute('PUT', $path, self::callback($callback));
    }
1027458
function binary($path) {
        if (function_exists('exec')) {
            exec($path.' -v 2>&1',$out,$ret);
            if ($ret==0 && preg_match('/cli/',@$out[0],$out))
                $this->binary=$path;
        }
        return $this->binary;
    }
949511
public function delete( $path, callable $callback ) {
        $route = new Route( 'DELETE', $path, $callback );
        $this->_routes[] = $route;
        return $route;
    }
301751
public function post(string $path, callable $callback, int $priority = 0)
    {
        return $this->route('post', $path, $callback, $priority);
    }
957617
protected function replaceToken($path, array $params)
    {
        $i=0;
        $path = preg_replace_callback('/@(\w+)|(\*)/', function($match) use(&$i,$params) {
            if (isset($match[1]) &&
                array_key_exists($match[1],$params)) {
                return $params[$match[1]];
            }
            if (isset($match[2]) &&
                array_key_exists($match[2],$params)) {
                if (!is_array($params[$match[2]])) {
                    return $params[$match[2]];
                }

                return $params[$match[2]][$i-1];
            }

            return $match[0];
        }, $path);

        return $path;
    }
994845
protected static function callback($callback)
    {
        if( is_string($callback) && ! is_callable($callback) )
        {
            return self::controllerCallback($callback);
        }

        return $callback;
    }
1312714
public function delete($path, $callback)
    {
        Argument::i()
            //argument 1 should be a string
            ->test(1, 'string')
            //argument 2 should be callable
            ->test(2, 'callable');
        
        return $this->route('delete', $path, $callback);
    }
1284390
public function watch($path, $callback)
	{
		if (!is_callable($callback)) {
			return null;
		}
		
		if ($this->zookeeper->exists($path)) {
			if (!isset($this->callback[$path])) {
				$this->callback[$path] = array();
			}
			if (!in_array($callback, $this->callback[$path])) {
				$this->callback[$path][] = $callback;
				return $this->zookeeper->get($path, array($this, 'watchCallback'));
			}
		}
	}