[英]Handle Method not allowed in slim 3
Need you help to figure this out.需要你帮忙解决这个问题。 i developed my website in Slim 3 framework.
我在 Slim 3 框架中开发了我的网站。 I wanted to handle " Method not allowed. Must be one of: POST " message which i get when i am using browser back and forward buttons.
我想处理“不允许的方法。必须是:POST ”消息之一,这是我在使用浏览器后退和前进按钮时收到的。
I want to redirect to a different page when if the route is post and when user clicks on browser back or forward page.
When the post route is called is there a way where i can detect the that it is post method call and redirect him to a different get route.当 post 路由被调用时,有没有一种方法可以让我检测到它是 post 方法调用并将他重定向到不同的 get 路由。
Another syntax solution另一种语法解决方案
$notAllowedHandler = function ($c) {
return function ($request, $response) use ($c) {
return $response
->withJson(
[
"status" => false,
"message" => "Your custom message",
"data" => [],
]
)
->withStatus(400);
};
};
$app = new App(
[
'notAllowedHandler' => $notAllowedHandler,
]
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.