Skip to content

Instantly share code, notes, and snippets.

@liorksh
Last active May 18, 2018 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liorksh/de8bfabe2bd5dd08946d3e7c70e903eb to your computer and use it in GitHub Desktop.
Save liorksh/de8bfabe2bd5dd08946d3e7c70e903eb to your computer and use it in GitHub Desktop.
Lambda input stream
public APIGatewayProxyResponse StreamHandler(Stream input, ILambdaContext context)
{
string inputString = string.Empty;
LambdaLogger.Log("started 'FunctionHandler' method");
if (input != null)
{
StreamReader streamReader = new StreamReader(input);
inputString = streamReader.ReadToEnd();
if (inputString.IndexOf("name") > 0)
{
inputString = inputString.Substring(inputString.IndexOf("name"), 6);
}
}
inputString = "received the following string: " + inputString;
var response = new APIGatewayProxyResponse
{
StatusCode = (int)HttpStatusCode.OK,
Body = inputString + DateTime.Now.ToString("hh:mm:ss"),
Headers = new Dictionary<string, string> { { "Content-Type", "text/plain" } }
};
return response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment