Jose Cabrera Zuniga
Jose Cabrera Zuniga

Reputation: 2619

Calling a scala function with a request from another function

I have a scala function that looks like:

   def myFunction(x: Option[String]) = Action { request =>
           ...
           ...
           ...
   }

I want to call this function from another scala function. How can this be done? What should request match to?

Action is defined in play.api.mvc._

https://www.playframework.com/documentation/2.0/api/scala/play/api/mvc/Action.html

Typically myFunction is called through a post command as myFunction has some commands to save the info coming through request into a DB. However, I need those commands to be executed from a call inside another scala function so I was wondering how to call myFunction from the other scala function (both functions are in the same application). Out of that, I need no other thing. We could make the assumption that both functions are within the same package.

Upvotes: 0

Views: 146

Answers (1)

Shweta Valunj
Shweta Valunj

Reputation: 158

Is the function part of a class? You can create an instance of class and call myFunction. Or you can use wSClient to form a request.

Upvotes: 0

Related Questions