Skip to content

Commit

Permalink
Merge pull request #36 from dwyl/ping-lambda-in-pixel-handler-issue#35
Browse files Browse the repository at this point in the history
invoke lambda function in pixel handler for #35
  • Loading branch information
SimonLab authored May 11, 2020
2 parents 6396591 + 69a04b3 commit b4c2c4f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/app_web/controllers/sent_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ defmodule AppWeb.SentController do
end

def pixel(conn, _params) do
# warm up the lambda function so emails are sent instantly!
payload = %{"ping" => :os.system_time(:millisecond), key: "ping"}
# IO.inspect(payload, label: "payload ping/2:151")
# see: https://github.com/dwyl/elixir-invoke-lambda-example
lambda = System.get_env("AWS_LAMBDA_FUNCTION")
ExAws.Lambda.invoke(lambda, payload, "no_context")
|> ExAws.request(region: System.get_env("AWS_REGION"))
|> IO.inspect(label: "ExAws.Lambda ping response")

conn # instruct browser not to cache the image
|> put_resp_header("cache-control", "no-store, private")
|> put_resp_header("pragma", "no-cache")
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule App.MixProject do
def project do
[
app: :app,
version: "1.0.0",
version: "1.0.1",
elixir: "~> 1.10",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix, :gettext] ++ Mix.compilers(),
Expand Down

0 comments on commit b4c2c4f

Please sign in to comment.