Last active
June 30, 2017 16:56
-
-
Save mchv/aebe1ce3b138dfdaf006c239b1f942a1 to your computer and use it in GitHub Desktop.
Old style playframework controller to reduce boilerplate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package play.api.mvc.legacy | |
import play.api.mvc._ | |
class Controller extends BaseController { | |
override protected def controllerComponents: ControllerComponents = { | |
Controller.components /* we don't null check here to avoid the cost associated to it - we expect devs to have done the init properly */ | |
} | |
} | |
object Controller { | |
private var components: ControllerComponents = null | |
/* | |
This need to be called when you initialise the app in app compoments | |
*/ | |
def init(c: ControllerComponents) = { | |
components = c | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment