1717 */
1818package com .github .kaklakariada .aws .lambda .model .response ;
1919
20+ import static java .util .Collections .emptyMap ;
21+
2022import java .util .Base64 ;
21- import java .util .Collections ;
2223import java .util .Map ;
2324
2425import com .fasterxml .jackson .annotation .JsonProperty ;
@@ -33,19 +34,31 @@ public ApiGatewayResponse(int statusCode, Map<String, String> headers, String bo
3334 this (statusCode , headers , body , false );
3435 }
3536
37+ public ApiGatewayResponse (int statusCode , Map <String , String > headers , byte [] body ) {
38+ this (statusCode , headers , base64Encode (body ), true );
39+ }
40+
3641 private ApiGatewayResponse (int statusCode , Map <String , String > headers , String body , boolean base64Encoded ) {
3742 this .statusCode = statusCode ;
3843 this .headers = headers ;
3944 this .body = body ;
4045 this .base64Encoded = base64Encoded ;
4146 }
4247
48+ public static ApiGatewayResponse ok (Map <String , String > headers , String body ) {
49+ return new ApiGatewayResponse (200 , headers , body );
50+ }
51+
4352 public static ApiGatewayResponse ok (String body ) {
44- return new ApiGatewayResponse (200 , Collections .emptyMap (), body );
53+ return ok (emptyMap (), body );
54+ }
55+
56+ public static ApiGatewayResponse ok (Map <String , String > headers , byte [] body ) {
57+ return new ApiGatewayResponse (200 , headers , base64Encode (body ), true );
4558 }
4659
4760 public static ApiGatewayResponse ok (byte [] body ) {
48- return new ApiGatewayResponse ( 200 , Collections . emptyMap (), base64Encode ( body ), true );
61+ return ok ( emptyMap (), body );
4962 }
5063
5164 private static String base64Encode (byte [] body ) {
0 commit comments