Last active
September 27, 2022 15:09
-
-
Save nuboat/bd2ff00213d346560d5f322b42412ebd to your computer and use it in GitHub Desktop.
This file contains 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
package cc.peerapat; | |
import com.amazonaws.services.lambda.runtime.Context; | |
import com.amazonaws.services.lambda.runtime.RequestHandler; | |
import com.amazonaws.services.lambda.runtime.events.APIGatewayV2HTTPEvent; | |
import com.amazonaws.services.lambda.runtime.events.APIGatewayV2HTTPResponse; | |
import java.util.HashMap; | |
import java.util.Map; | |
/** | |
* cc.peerapat.BahtTextHTTP::handleRequest | |
*/ | |
public class BahtTextHTTP implements RequestHandler<APIGatewayV2HTTPEvent, APIGatewayV2HTTPResponse> { | |
final Map<String, String> headers = new HashMap<>(); | |
public BahtTextHTTP() { | |
headers.put("Content-Type", "text/plain"); | |
} | |
@Override | |
public APIGatewayV2HTTPResponse handleRequest(final APIGatewayV2HTTPEvent request, final Context context) { | |
return buildResponse(BahtText.toText(request.getBody())); | |
} | |
private APIGatewayV2HTTPResponse buildResponse(final String body) { | |
final APIGatewayV2HTTPResponse response = new APIGatewayV2HTTPResponse(); | |
response.setIsBase64Encoded(false); | |
response.setStatusCode(200); | |
response.setHeaders(headers); | |
response.setBody(body); | |
return response; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment