qqq
This commit is contained in:
+28
-8
@@ -58,23 +58,33 @@ class Router
|
||||
/**
|
||||
* @param string $route
|
||||
* @param string $handler
|
||||
* @throws
|
||||
* @param bool $enableOption
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public static function post(string $route, string $handler): void
|
||||
public static function post(string $route, string $handler, bool $enableOption = true): void
|
||||
{
|
||||
$router = Kiri::getDi()->get(DataGrip::class)->get(static::$type);
|
||||
$router->addRoute([RequestMethod::REQUEST_POST], $route, $handler);
|
||||
if ($enableOption) {
|
||||
$options = [di(OptionsController::class), 'index'];
|
||||
$router->addRoute([RequestMethod::REQUEST_OPTIONS], $route, $options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $route
|
||||
* @param string $handler
|
||||
* @throws
|
||||
* @param bool $enableOption
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public static function get(string $route, string $handler): void
|
||||
public static function get(string $route, string $handler, bool $enableOption = true): void
|
||||
{
|
||||
$router = Kiri::getDi()->get(DataGrip::class)->get(static::$type);
|
||||
$router->addRoute([RequestMethod::REQUEST_GET], $route, $handler);
|
||||
if ($enableOption) {
|
||||
$options = [di(OptionsController::class), 'index'];
|
||||
$router->addRoute([RequestMethod::REQUEST_OPTIONS], $route, $options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -104,12 +114,17 @@ class Router
|
||||
/**
|
||||
* @param string $route
|
||||
* @param string $handler
|
||||
* @throws
|
||||
* @param bool $enableOption
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public static function delete(string $route, string $handler): void
|
||||
public static function delete(string $route, string $handler, bool $enableOption = true): void
|
||||
{
|
||||
$router = Kiri::getDi()->get(DataGrip::class)->get(static::$type);
|
||||
$router->addRoute([RequestMethod::REQUEST_DELETE], $route, $handler);
|
||||
if ($enableOption) {
|
||||
$options = [di(OptionsController::class), 'index'];
|
||||
$router->addRoute([RequestMethod::REQUEST_OPTIONS], $route, $options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -128,12 +143,17 @@ class Router
|
||||
/**
|
||||
* @param string $route
|
||||
* @param string $handler
|
||||
* @throws
|
||||
* @param bool $enableOption
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public static function put(string $route, string $handler): void
|
||||
public static function put(string $route, string $handler, bool $enableOption = true): void
|
||||
{
|
||||
$router = Kiri::getDi()->get(DataGrip::class)->get(static::$type);
|
||||
$router->addRoute([RequestMethod::REQUEST_PUT], $route, $handler);
|
||||
if ($enableOption) {
|
||||
$options = [di(OptionsController::class), 'index'];
|
||||
$router->addRoute([RequestMethod::REQUEST_OPTIONS], $route, $options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user