File tree 2 files changed +23
-5
lines changed
commons/src/main/java/org/restheart/exchange
2 files changed +23
-5
lines changed Original file line number Diff line number Diff line change 33
33
*
34
34
* @author Andrea Di Cesare {@literal <[email protected] >}
35
35
*/
36
- public class BsonRequest extends ServiceRequest <BsonValue > {
36
+ public class BsonRequest extends ServiceRequest <BsonValue > implements RawBodyAccessor <String > {
37
+
38
+ private String rawBody ;
39
+
37
40
protected BsonRequest (HttpServerExchange exchange ) {
38
41
super (exchange );
39
42
}
@@ -49,9 +52,15 @@ public static BsonRequest of(HttpServerExchange exchange) {
49
52
@ Override
50
53
public BsonValue parseContent () throws IOException , BadRequestException {
51
54
try {
52
- return BsonUtils .parse (ChannelReader .readString (wrapped ));
53
- } catch (JsonParseException jpe ) {
55
+ rawBody = ChannelReader .readString (wrapped );
56
+ return BsonUtils .parse (rawBody );
57
+ } catch (JsonParseException jpe ) {
54
58
throw new BadRequestException (jpe .getMessage (), jpe );
55
59
}
56
60
}
61
+
62
+ @ Override
63
+ public final String getRawBody () {
64
+ return rawBody ;
65
+ }
57
66
}
Original file line number Diff line number Diff line change 33
33
*
34
34
* @author Andrea Di Cesare {@literal <[email protected] >}
35
35
*/
36
- public class JsonRequest extends ServiceRequest <JsonElement > {
36
+ public class JsonRequest extends ServiceRequest <JsonElement > implements RawBodyAccessor <String > {
37
+
38
+ private String rawBody ;
39
+
37
40
protected JsonRequest (HttpServerExchange exchange ) {
38
41
super (exchange );
39
42
}
@@ -50,12 +53,18 @@ public static JsonRequest of(HttpServerExchange exchange) {
50
53
public JsonElement parseContent () throws IOException , BadRequestException {
51
54
if (wrapped .getRequestContentLength () > 0 ) {
52
55
try {
53
- return JsonParser .parseString (ChannelReader .readString (wrapped ));
56
+ rawBody = ChannelReader .readString (wrapped );
57
+ return JsonParser .parseString (rawBody );
54
58
} catch (JsonSyntaxException jse ) {
55
59
throw new BadRequestException (jse .getMessage (), jse );
56
60
}
57
61
} else {
58
62
return null ;
59
63
}
60
64
}
65
+
66
+ @ Override
67
+ public String getRawBody () {
68
+ return rawBody ;
69
+ }
61
70
}
You can’t perform that action at this time.
0 commit comments