Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.x] Fixes route() base uri, domain, and query parameters #88

Merged
merged 10 commits into from
Aug 16, 2023

Conversation

nunomaduro
Copy link
Member

@nunomaduro nunomaduro commented Aug 16, 2023

Fixes #85.

This pull request fixes three things when using the route() function and adds versioning to the cache generated by Folio's routes:

  1. Extra parameters sent as the second parameter to the route() function are now sent as query parameters, just like the regular behavior of the route() function.
// before:
route('posts', ['page' => 1], false); // /posts
// with this pr:
route('posts', ['page' => 1], false); // /posts?page=1
  1. The base URI of the mounted path is now respected. For example, Folio::uri('/1')->path(...) will generate a URL that contains that URI.
Folio::uri('/v1')->path('pages/version-one');

// before:
route('posts', ['page' => 1], false); // /posts
// with this pr:
route('posts', ['page' => 1], false); // /v1/posts?page=1
  1. The domain of the Folio's mount is now respected, similar to the regular behavior of the route() function. For example, Folio::domain('podcasts.com')->... will generate a route() result with the http://podcasts.com/{...} domain.
Folio::domain('{account}.podcasts.com')->uri('/v1')->path('pages/version-one');

// before:
route('posts', ['account' => 'foo', 'page' => 1]); // http://localhost/posts
// with this pr:
route('posts', ['account' => 'foo', 'page' => 1]); // http://foo.podcasts.com/posts
  1. Finally, versioning is introduced to the cache. This means that if FolioRoutes::version changes, the cached version is ignored until a new route:cache command is invoked.

@nunomaduro nunomaduro marked this pull request as ready for review August 16, 2023 15:34
@taylorotwell taylorotwell merged commit 7a6f613 into master Aug 16, 2023
6 checks passed
@taylorotwell taylorotwell deleted the fix/route-domain-query-parameters-and-uri branch August 16, 2023 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add query parameters to named routes.
2 participants