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?
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...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.