ceran ceran - 1 year ago 198
Scala Question

play-silhouette: specify body parser for (Un)SecuredAction?

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
, but not with silhouette's
. Is there a way to do this without having to fall back to silhouette's
or having to check manually if the body is actually JSON?

Answer Source

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...
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download