I try to provide module specific routing that can be included in Play applications using the standard route file conf/routes
as:
-> /psmod1 com.escalesoft.psmod1.ctrl.Routes
Compilation error obtained:
type Psmod1Assets is not a member of package com.escalesoft.psmod1.ctrl
To accomplish this I followed two steps as instructed in the official documentation at Assets and controller classes should be all defined in the controllers.admin package
1. Define Assets and controller classes in their own package
Define Assets class Psmod1Assets.scala
as:
package com.escalesoft.psmod1.ctrl import play.api.http.LazyHttpErrorHandlerobjectclass Psmod1Assets extends controllers.AssetsBuilder(LazyHttpErrorHandler)
The above object definition replacement by class fixes the problem
2. Splitting the route file
Define module specific route file /conf/com.escalesoft.psmod1.ctrl.routes
as:
# Routes
# Home page
GET / com.escalesoft.psmod1.ctrl.Application.index
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file com.escalesoft.psmod1.ctrl.Psmod1Assets.versioned(path="/public", file: Asset)
If you like you can check or clone the code of my small test project on github:
- Online: https://github.com/refond/psmod1/tree/routing_issue
- With git:
git clone -b routing_issue https://github.com/refond/psmod1.git
The project is configured to work using standard controllers.Assets
.
Go to /conf/com.escalesoft.psmod1.ctrl.routes
file (check it at com.escalesoft.psmod1.ctrl.routes) and replace line with controllers.Assets
by line with com.escalesoft.psmod1.ctrl.Psmod1Assets
to reproduce the compilation error.
I already checked the following resources:
- Looks like a duplicate but the approved answer does not address the current problem Play Framework [2.4.x] how to address public assets in a sub module's routing file
- Interesting but outdated: http://www.objectify.be/wordpress/?p=363
- General https://www.playframework.com/documentation/2.4.x/Modules