index/src/Routing/IRouter.php

82 lines
2.1 KiB
PHP

<?php
// IRouter.php
// Created: 2023-01-06
// Updated: 2023-01-06
namespace Index\Routing;
interface IRouter {
/**
* Apply middleware functions to a path.
*
* @param string $path Path to apply the middleware to.
* @param callable $handler Middleware function.
*/
public function use(string $path, callable $handler): void;
/**
* Merges another router with this one with possibility of changing its root.
*
* @param string $path Base path to use.
* @param Router $router Router object to inherit from.
*/
public function merge(string $path, Router $router): void;
/**
* Adds a new route.
*
* @param string $method Request method.
* @param string $path Request path.
* @param callable $handler Request handler.
*/
public function add(string $method, string $path, callable $handler): void;
/**
* Adds a new GET route.
*
* @param string $path Request path.
* @param callable $handler Request handler.
*/
public function get(string $path, callable $handler): void;
/**
* Adds a new POST route.
*
* @param string $path Request path.
* @param callable $handler Request handler.
*/
public function post(string $path, callable $handler): void;
/**
* Adds a new DELETE route.
*
* @param string $path Request path.
* @param callable $handler Request handler.
*/
public function delete(string $path, callable $handler): void;
/**
* Adds a new PATCH route.
*
* @param string $path Request path.
* @param callable $handler Request handler.
*/
public function patch(string $path, callable $handler): void;
/**
* Adds a new PUT route.
*
* @param string $path Request path.
* @param callable $handler Request handler.
*/
public function put(string $path, callable $handler): void;
/**
* Adds a new OPTIONS route.
*
* @param string $path Request path.
* @param callable $handler Request handler.
*/
public function options(string $path, callable $handler): void;
}