35 lines
707 B
PHP
35 lines
707 B
PHP
<?php
|
|
// HttpRoute.php
|
|
// Created: 2024-03-28
|
|
// Updated: 2024-03-28
|
|
|
|
namespace Index\Http\Routing;
|
|
|
|
use Attribute;
|
|
|
|
/**
|
|
* Provides an attribute for marking methods in a class as a route.
|
|
*/
|
|
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
|
|
class HttpRoute extends HandlerAttribute {
|
|
private string $method;
|
|
|
|
/**
|
|
* @param string $method
|
|
* @param string $path
|
|
*/
|
|
public function __construct(string $method, string $path) {
|
|
parent::__construct($path);
|
|
$this->method = $method;
|
|
}
|
|
|
|
/**
|
|
* Returns the target method name.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getMethod(): string {
|
|
return $this->method;
|
|
}
|
|
}
|