Last active
December 29, 2015 17:29
-
-
Save rch850/7704250 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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