Reputation: 1515
Imagine that I have a route in my Play application that returns some JSON :
GET /getjson controllers.someMethod()
I want this route to be available from within my application because I want to call it to get the JSON it returns and do something with it. But, I don't want it to be available from the outside. I don't want the http://mywebsite.com/getjson to respond to a client visiting my website.
How should I do it ?
Upvotes: 0
Views: 362
Reputation: 492
firstly, delete the following route item from conf
GET /getjson controllers.someMethod()
secondly, create another object whose definition is the same as the controllers.someMethod(), but not extends from Controller
last, delete the definition of the "controllers.someMethod()".
Then, the redefinition of the someMethod() is just available in the internal, but can not be called from the outside which means the "/getjson" url is unavailable and can not be reached.
Good luck.
Upvotes: 1
Reputation: 802
Whatever you define in the routes (controller
layer) will be available to other services as RESTFUL endpoints.
For your case, you can simply make someMethod() as a method at service
layer. There is not need to put it at the controller
layer.
Upvotes: 3