Skip to content

Commit

Permalink
add /ping to wake Heroku app see: https://github.com/dwyl/ping
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Jul 22, 2020
1 parent 46c45c7 commit 2f26ed1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ you can setup in ***5 minutes***.
<!-- uncomment when service is working ...
[![Inline docs](http://inch-ci.org/github/dwyl/auth.svg?branch=master&style=flat-square)](http://inch-ci.org/github/dwyl/auth)
-->
![wake-sleeping-heroku-app](https://dwylauth.herokuapp.com/ping)

</div>

Expand Down
8 changes: 8 additions & 0 deletions lib/auth_web/controllers/ping_controller.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
defmodule AuthWeb.PingController do
use AuthWeb, :controller

# see: github.com/dwyl/ping
def ping(conn, params) do
Ping.render_pixel(conn, params)
end
end
3 changes: 3 additions & 0 deletions lib/auth_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ defmodule AuthWeb.Router do
# get "/auth/password/new", AuthController, :password_input
post "/auth/password/create", AuthController, :password_create
post "/auth/password/verify", AuthController, :password_prompt

# https://github.com/dwyl/ping
get "/ping", PingController, :ping
end

pipeline :auth do
Expand Down
1 change: 1 addition & 0 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"phoenix_html": {:hex, :phoenix_html, "2.14.2", "b8a3899a72050f3f48a36430da507dd99caf0ac2d06c77529b1646964f3d563e", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "58061c8dfd25da5df1ea0ca47c972f161beb6c875cd293917045b92ffe1bf617"},
"phoenix_live_reload": {:hex, :phoenix_live_reload, "1.2.2", "38d94c30df5e2ef11000697a4fbe2b38d0fbf79239d492ff1be87bbc33bc3a84", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "a3dec3d28ddb5476c96a7c8a38ea8437923408bc88da43e5c45d97037b396280"},
"phoenix_pubsub": {:hex, :phoenix_pubsub, "2.0.0", "a1ae76717bb168cdeb10ec9d92d1480fec99e3080f011402c0a2d68d47395ffb", [:mix], [], "hexpm", "c52d948c4f261577b9c6fa804be91884b381a7f8f18450c5045975435350f771"},
"ping": {:hex, :ping, "1.0.1", "1f44c7b7151af18627edbd7946a376935871f285fc9c11e9f16ddb1555ea65b5", [:mix], [{:plug, "~> 1.10.1", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "c1421bebcb6601e7fb1158700ca99eb2dc0976b45fe2a26023db5a9318aadfa6"},
"plug": {:hex, :plug, "1.10.3", "c9cebe917637d8db0e759039cc106adca069874e1a9034fd6e3fdd427fd3c283", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "01f9037a2a1de1d633b5a881101e6a444bcabb1d386ca1e00bb273a1f1d9d939"},
"plug_cowboy": {:hex, :plug_cowboy, "2.3.0", "149a50e05cb73c12aad6506a371cd75750c0b19a32f81866e1a323dda9e0e99d", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "bc595a1870cef13f9c1e03df56d96804db7f702175e4ccacdb8fc75c02a7b97e"},
"plug_crypto": {:hex, :plug_crypto, "1.1.2", "bdd187572cc26dbd95b87136290425f2b580a116d3fb1f564216918c9730d227", [:mix], [], "hexpm", "6b8b608f895b6ffcfad49c37c7883e8df98ae19c6a28113b02aa1e9c5b22d6b5"},
Expand Down
10 changes: 10 additions & 0 deletions test/auth_web/controllers/ping_controller_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
defmodule AuthWeb.PingControllerTest do
use AuthWeb.ConnCase

test "GET /ping (GIF) renders 1x1 pixel", %{conn: conn} do
conn = get(conn, Routes.ping_path(conn, :ping))
assert conn.status == 200
assert conn.state == :sent
assert conn.resp_body =~ <<71, 73, 70, 56, 57>>
end
end

0 comments on commit 2f26ed1

Please sign in to comment.