LaraCrafts / laravel-geo-routes

GeoLocation restricted routes for Laravel
MIT License
111 stars 5 forks source link

Add the `geo` attribute. #29

Closed yak0d3 closed 5 years ago

yak0d3 commented 5 years ago

This PR adds a geo attribute to the route action array which is more "Laravel-ish".

This will improve performance as we no longer do need to serialize the callback and follow a certain "schema" to define the middleware parameters string as in the following piece of code:

'geo:' . $this->strategy . ',' . implode('&', $this->countries) .
            ($this->callback ? ',' . serialize($this->callback) : '');

Note: There is an increase of 20 seconds in the build time, this does not mean the code is slower as the tests now have 3 more assertions.

Builds Screenshot

Developers can now also define route attributes manually which is not the best way to do so, but for developers that prefer verbosity, they can now write something like the following:

Route::get('/foo', ['geo' => ['strategy' => 'allow', 'countries' => ['us', 'ca'], 'callback' => 'Foo@bar']]);
axlon commented 5 years ago

@yak0d3 build times are completely irrelevant to package performance, no worries :) Slower builds can have all kinds of causes not related to our code