-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Extracted HttpErrorHandler interface from Global #3444
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
Conversation
jroper
commented
Sep 25, 2014
- Play will by default try and load one of these from the root package called ErrorHandler
- If none is found, it will fallback to one that delegates to Global, so that Global.onError etc methods still work for legacy apps
- Added a new mechanism to the Reflect utils to load bindings for either a Scala interface, or a Java interface with an adapter to the Scala interface
- Updated documentation, including removing documentation on old Global methods
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.
Why aren’t we sure here that there is an Application?
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.
It may have failed to compile or load (in dev mode). At some point I'd like to change things so that if it does fail to compile or load, an error application is returned that just responds to every request by rendering the error, that will make so much of the logic here so much simpler. But I think that's a separate change.
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.
Yes, I was thinking of doing something like this when I was writing the Akka HTTP backend. Or at least a MaybeLoadedApplication which wraps either a loaded application or a not-loaded application and which the Netty and Akka HTTP servers can send requests too.
|
I don’t think this is a good idea to reflectively load the |
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.
We should not have this file.
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.
Why not? Unfortunately, we need to instantiate RequestHeaders in the tests, and there's no other way to do it. Now that the app doesn't depend so much on global state, we can start moving tests out of the integration test project, but some things are needed to do that, such as a way to instantiate a RequestHeader.
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.
I don’t see the point of having two separate types, Request and FakeRequest. Why not just have Request? Just put the required methods in this type.
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.
Request is also just a trait that doesn't have any public concrete implementations.
While I completely agree with you, providing either Request or RequestHeader case classes are separate changes in their own right that will have a fundamental impact on Play's public API. They need to be carefully thought through, in particular, we'd like to preparse many headers, including the session, and make them strongly typed, but we don't want two sources of truth (both the headers map and the strongly typed parsed values).
In contrast, this FakeRequest is just something introduced for Play's tests, it is not public API, and so can be done with little thought. I hope some day we can get rid of it, but that day isn't today.
|
If you're using runtime dependency injection, you're using reflection anyway everywhere to instantiate everything. If you're using compile time dependency injection, then reflection is just to load the ApplicationLoader. |
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.
Typo: "malformated" -> "malformed" or "badly formatted"
|
LGTM James and I had a bit of a talk offline about this PR. I'll just mention some of the things I raised with James. I didn't have any solutions to these issues, these were just comments.
|
* Play will by default try and load one of these from the root package called ErrorHandler * If none is found, it will fallback to one that delegates to Global, so that Global.onError etc methods still work for legacy apps * Added a new mechanism to the Reflect utils to load bindings for either a Scala interface, or a Java interface with an adapter to the Scala interface * Updated documentation, including removing documentation on old Global methods
282b6bb to
6d93117
Compare
|
@play-pull-request-validator again please |
Extracted HttpErrorHandler interface from Global