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
Add static routes #101
Add static routes #101
Conversation
yiiliveext
commented
Mar 29, 2021
Q | A |
---|---|
Is bugfix? | ❌ |
New feature? | ✔️ |
Breaks BC? | ❌ |
Fixed issues | #100 |
Wouldn't Route::static make more sense? Since those will not be handled by Yii, Route::get is actually not the proper call. |
What do you mean? //Assets for urlGenerator, requests will not be handled by Yii
Route::get('/images/{file}')
->static()
->host($appParams->assetDomain)
->name('img'), That's all. You can use static routes in a common routes file/array. |
I meant //Assets for urlGenerator, requests will not be handled by Yii
Route::static('/images/{file}')
->host($appParams->assetDomain)
->name('img'), Sorry, I commented without enough information. |
Maybe it makes sense. Need a review from more devs. |
There was an ability to make URL rule with matching only or generation only in Yii 2: https://github.com/yiisoft/yii2/blob/master/framework/web/UrlRule.php#L38 I haven't personally used it myself so I'm not sure about use cases. |
Done |
tests/RouteTest.php
Outdated
Route::static('/')->middleware(fn () => 1); | ||
} | ||
|
||
public function testStaticFailWihAddAction(): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public function testStaticFailWihAddAction(): void | |
public function testStaticFailWithAddAction(): void |
src/Route.php
Outdated
* | ||
* @return self | ||
*/ | ||
public static function static(string $pattern): self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need for a separate method. Generation-only route is the one that doesn't have action.
👍 |