playframework - Scala Play 2.5 Turning an Action into A Result -


in play scala project, i'm returning object inside of controller type:

play.api.mvc.action[play.api.libs.json.jsvalue however, play complaining expecting play.api.mvc.result. according docs, action function handles request , generates result.

def mycontroller = myspecialfunction.asyc(prase.tolerantjson) { implicit request => {         {             ... stuff ...         } yield {             myfunction()         }     } } 

in case, myfunction has return type of play.api.mvc.action[play.api.libs.json.jsvalue.

i want return result, , i'm not sure how correctly call function

your action.async block expects function request future[result].

now, myfunction() inside yield block returning jsvalue return type. if comprehension on futures, output of for-comprehension becomes future[jsvalue]. play expects future[result]. transform result future[result]. final output type should future[result].

for example

action.async { req =>   val resultfuture =      {       _ <- getusersfuture       _ <- dosomethingfuture     } yield (myfunction)    resultfuture.map { json => ok(json) } } 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -