I am trying to use Lumen to develop an interface. After tossing it down, I found that the server used the GET Method Request interface for the first URL verification, and then used the POST method access interface. So I want to register the route as a response to GET and POST requests: I checked the laravel5 text... I am trying to use Lumen to develop an interface. After tossing it down, I found that the server used the GET Method Request interface for the first URL verification, and then used the POST method access interface.
Therefore, I want to register the route as a response to GET and POST requests:
I checked the laravel 5 Documentation and matched the route for multiple requests:
Route::match(['get', 'post'], '/', function(){ return 'Hello World';});
Register as responding to all requests:
Route::any('foo', function(){ return 'Hello World';});
Then I try to set the original$app->get()
And$app->post()
Change$app->any()
, Reproduction error:
Fatal error: Call to undefined method Laravel \ Lumen \ Application: any ()
Therefore, may I ask:In the Lumen framework, what should I do if I want to register a path as a response to all requests (or respond to both POST and GET requests?
Reply content:
I am trying to use Lumen to develop an interface. After tossing it down, I found that the server used the GET Method Request interface for the first URL verification, and then used the POST method access interface.
Therefore, I want to register the route as a response to GET and POST requests:
I checked the laravel 5 Documentation and matched the route for multiple requests:
Route::match(['get', 'post'], '/', function(){ return 'Hello World';});
Register as responding to all requests:
Route::any('foo', function(){ return 'Hello World';});
Then I try to set the original$app->get()
And$app->post()
Change$app->any()
, Reproduction error:
Fatal error: Call to undefined method Laravel \ Lumen \ Application: any ()
Therefore, may I ask:In the Lumen framework, what should I do if I want to register a path as a response to all requests (or respond to both POST and GET requests?
Copy A get post and write each time.
Or the Function name does not contain the request method. get post is defined once in the route.
You can extend the Application class and write a method map by yourself.
addRoute($method, $uri, $action); } }}
Then in routes. php
$app->map(['GET','POST'], 'foo', function() { return 'Hello World';});