flightphp / core

An extensible micro-framework for PHP
https://docs.flightphp.com
MIT License
2.62k stars 409 forks source link

Route Methods #479

Closed JmzTaylor closed 1 year ago

JmzTaylor commented 1 year ago

So I am not sure if I am just misreading the routes and such but given the example below, the first route is always picked up on POST methods. If I understand this correctly, it shouldn't. The only way the POST route is picked up is if its before the regular route. Changing no other code than moving the POST route above the other, it will work as expected.

Flight::route('/someroute', function () {});

Flight::route('POST /someroute', function () {});
magikstm commented 1 year ago

The first route being set to all types, it'll be picked for a POST.

If you wish for the second one to be picked, changing the order is the right way.

It is working according to specs.


Related doc: By default, route patterns are matched against all request methods. Ref: https://github.com/mikecao/flight#method-routing


Related doc: Routes are matched in the order they are defined. The first route to match a request will be invoked. Ref: https://github.com/mikecao/flight#routing