I'm relatively new to functional programming in scala. I came across the flowing method. I have been unable to figure out exactly what it is doing?
def getPostsByFilters = (authenticatedPublicApiPostArticleAction andThen rateLimitedApiAction).async(BodyParsers.parse.tolerantJson) { implicit request =>
implicit val apiKey = Some(request.apiKey)
request.body.validate[ArticlePostQuery] fold(
errors => futureBadRequest(errors.toString()),
articleQuery => verifyPostQueryParams(articleQuery, verifiedApiRequest => {
val PostsNetwork = PostsNetwork(true, verifiedApiRequest.contentType, verifiedApiRequest.orderBy)
apiArticleService.findApiArticlesWithPostRequest(verifiedApiRequest, PostsNetwork) map (articles => wrapUpResultsToJson(ApiPosts(articles)))
}))
}
It is in a play API controller and the method is mapped to a post request in the route file.
I know it take a json post request and returns a json response, but can someone explain what is actually happening and if there is a way to refactor it to make it more readable?