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

Move 'installation:complete' to web instead of per route #1467

Merged
merged 4 commits into from
Sep 5, 2022

Conversation

ildyria
Copy link
Member

@ildyria ildyria commented Aug 18, 2022

Minor refactoring to simplify middleware in routes in web.php.

@ildyria ildyria requested a review from a team August 18, 2022 10:35
@codecov
Copy link

codecov bot commented Aug 18, 2022

Codecov Report

Merging #1467 (7f16ac8) into master (1c8eedb) will decrease coverage by 0.74%.
The diff coverage is n/a.

Copy link
Contributor

@qwerty287 qwerty287 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are Installation routes excluded from this?

@ildyria
Copy link
Member Author

ildyria commented Aug 18, 2022

Yes, because the installation routes are in web-install.php.
This middleware is just applied to web.php.
See app/Providers/RouteServiceProvider.php

@qwerty287
Copy link
Contributor

Why is this middleware not applied to the API? If there's no reason, you should apply it there too.

@nagmat84
Copy link
Collaborator

Yes, there is a reason. The API client expects JSON responses. A redirection to a HTML page (with the installer) is nothing an API client can handle.

@qwerty287
Copy link
Contributor

Does it return something else instead or does it just fail if there's e.g. a DB request?

@nagmat84
Copy link
Collaborator

If the request fails, it returns the error message of the code line which caused the request to fail as all failing requests do. If the request fails, it uses the normal error reporting mechanisms as always.

@qwerty287
Copy link
Contributor

Sure, but it would be better to report something like "not installed".

@nagmat84
Copy link
Collaborator

Definitely yes.

And I have checked to code again. When I wrote the exception handler and created the exception InstallationRequiredException, I had been better than I thought I had been. 😀 If the middleware attempts to assert that the installation is complete and finds the installation to be incomplete, then this middleware throws an InstallationRequiredException exception. The exception handler catches the exception but only replies with a redirection, if the client requested a HTML page not application/json. Otherwise, i.e. if the client wants application/json, then the error reporting proceeds normally and the client receives a proper InstallationRequiredException through JSON.

So back to what you have initially suggested in #1467 (comment).

We actually can apply this middleware to the API and we are good.

@ildyria ildyria added this to the 4.6.1 milestone Sep 3, 2022
@ildyria ildyria merged commit b31d345 into master Sep 5, 2022
@ildyria ildyria deleted the middleware-route-change branch September 5, 2022 10:12
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.

3 participants