HTTP 메서드 라우팅
같은 URL이라도 GET/POST에 따라 다른 처리를 할 수 있습니다.
현재 요청 정보
HTTP 메서드: GET
Routes.php — match()로 여러 메서드 허용
// GET과 POST 모두 허용
$routes->match(['get', 'post'], 'examples/routing/method', 'Examples\Routing::method');
// 이 라우트에 다른 메서드(PUT, DELETE 등)로 접근하면 404 오류
컨트롤러 — 메서드 분기 처리
public function method(): string
{
$httpMethod = $this->request->getMethod(); // 'get' 또는 'post'
return view('examples/routing/method', [
'httpMethod' => strtoupper($httpMethod),
]);
}