Skip to content

Instantly share code, notes, and snippets.

@rch850
Last active December 29, 2015 17:29
Show Gist options
  • Save rch850/7704250 to your computer and use it in GitHub Desktop.
Save rch850/7704250 to your computer and use it in GitHub Desktop.
public class RawJsonBodyParser extends Action.Simple {
@Override
public Result call(Context ctx) throws Throwable {
String rawBody = new String(ctx.request().body().asRaw().asBytes());
JsonNode json = Json.parse(rawBody);
ctx.args.put("json", json);
return delegate.call(ctx);
}
}
@BodyParser.Of(BodyParser.Raw.class)
@With(RawJsonBodyParser.class)
public class YourController extends Controller {
public static Result hoge() {
return ok(ctx().args.get("json") + "");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment