Reputation: 1412
I'm using silhouette for authentication in a play web application and want to do something like this:
def action = UnsecuredAction(BodyParsers.parse.json).async { implicit request =>
// use json
}
This seems to be possible when using Play's build-in Action
, but not with silhouette's UnsecuredAction
and SecuredAction
. Is there a way to do this without having to fall back to silhouette's (Un)SecuredRequestHandler
or having to check manually if the body is actually JSON?
Upvotes: 1
Views: 339
Reputation: 5156
You can parse your request body to JSON by using async(parse.json)
.
For example:
def index = silhouette.SecuredAction.async(parse.json) { implicit request =>
// Write your code here...
}
Upvotes: 3