Replies: 3 comments 3 replies
|
Hi, @anishb266! |
|
@anishb266 What is your goal / use case? Why you want to access the body in a filter? Maybe a filter is not what you want in the end. |
|
Not really an answer to your question, but for Play Java, there's this thing called ActionCreator, where you have access to the request body like this: import com.google.inject.Inject;
import play.http.DefaultActionCreator;
import play.mvc.Action;
import play.mvc.Http;
import play.mvc.Result;
import java.lang.reflect.Method;
import java.util.concurrent.CompletionStage;
public class ExampleActionCreator extends DefaultActionCreator {
@Inject
public ExampleActionCreator() {}
@Override
public Action.Simple createAction(Http.Request request, Method actionMethod) {
return new Action.Simple() {
@Override
public CompletionStage<Result> call(Http.Request req) {
req.body(); // <------------
return delegate.call(req);
}
};
}
}Unfortunately you simply do not have access to the request body in a |
Uh oh!
There was an error while loading. Please reload this page.
Please help. I'm trying to access the request body via EssentialFilter.
But the online documentation didn't show how to access it in the code.
Link - https://www.playframework.com/documentation/2.9.x/ScalaHttpFilters.
If someone can show an example of how to get the request body in the Essential Filter will be helpful.
All reactions