The route is defined as a `post` in Thinkphp5. How to customize the error when using `get` request

Thinkphp5 defines the route as a post , and how to customize the error when using get request

if a post route is defined in application/route.php in thinkphp5, as follows, how to customize the wrong content and return the wrong json when we request in the wrong way.

Route::group("user", function (){
   Route::post("/login", "api/User/login");
});

normal access, use post request. The result returned above is:

{
    "code": 10001,
    "msg": "",
    "request_url": "/index.php/user/login"
}

ask which Daniel to have a look!

Apr.30,2021

Route::miss(function () {
    return json(['code' => 999, 'msg' => '']);
});
  • Thinkphp route matching problem

    Route::post( xdk plan , xdk plan save ); Route::post( xdk plan :id fav , xdk plan fav ); Route::post( xdk plan :id comments , xdk plan comments ); is to build a restful style api xdk plan post xdk plan :id fav like xdk plan :id c...

    Mar.12,2021
Menu