Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play 2 modules: how to add routes without tight coupling?

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.

like image 901
Hbf Avatar asked Nov 23 '25 13:11

Hbf


2 Answers

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

like image 199
biesior Avatar answered Nov 25 '25 09:11

biesior


This is now supported in 2.1, see section "Allow more modularization for your projects" in the release notes. Good news!

like image 29
Hbf Avatar answered Nov 25 '25 10:11

Hbf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!