I am developing a Play 2 module that exposes some URLs and am wondering how I can "offer" these URLs to the Play application that is hosting my module.
Example: Suppose my module (called store) realizes a document repository, offering (amongst others) the URL document/<id> to read the document with id <id>. Depending on its needs, the application that uses this module may expose this URL under http://example.org/media/document/<id>, or under http://example.org/document/<id>, or something else.
Question: How does a module expose URLs (routes) to its encompassing application without hardcoding them?
Note: I am coming from Django and was looking for a mechanism similar to Django URLconfs.
You probably asking about HTTP routing
Note that you need put routing rulez in the main conf/routes file. It is supposed to be changed in version 2.1 of the Play.
Edit:
check for an example the sample of SecureSocial (there is also Scala version), check how the routes to the module are represented in the conf/routes
This is now supported in 2.1, see section "Allow more modularization for your projects" in the release notes. Good news!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With