Packages
messenger_bot
1.3.0
1.3.0
1.2.0
retired
1.1.0
retired
1.0.0
retired
1.0.0-rc.8
retired
1.0.0-rc.7
retired
1.0.0-rc.6
retired
1.0.0-rc.5
retired
1.0.0-rc.4
retired
1.0.0-rc.3
retired
1.0.0-rc.2
retired
1.0.0-rc.1
retired
1.0.0-beta9
retired
1.0.0-beta8
retired
1.0.0-beta7
retired
1.0.0-beta6
retired
1.0.0-beta5
retired
1.0.0-beta4
retired
1.0.0-beta3
retired
1.0.0-beta2
retired
1.0.0-beta10
retired
1.0.0-beta1
retired
0.9.2
retired
0.9.1
retired
0.9.0
retired
0.8.2
retired
0.8.1
retired
0.8.0
retired
0.7.3
retired
0.7.2
retired
0.7.1
retired
0.7.0
retired
0.6.0
retired
0.5.2
retired
0.5.1
retired
0.5.0
retired
0.4.0
retired
0.3.0
retired
0.2.1
retired
0.2.0
retired
0.1.0
retired
Unofficial Facebook Messenger Platform chatbot client and webhook handler
Current section
Files
Jump to
Current section
Files
lib/messenger_bot/web/plugs/app_identification.ex
defmodule MessengerBot.Web.Plug.AppIdentification do
@moduledoc false
############################################################################
# Plug implementation to identify Facebook App #
############################################################################
alias MessengerBot.Config
alias MessengerBot.Model.App
alias MessengerBot.Model.Error
alias MessengerBot.Web.Renderer
alias Plug.Conn
@behaviour Plug
@doc false
def init(opts) do
opts
end
@doc false
def call(conn, _) do
case app(conn.path_info) do
%App{id: _} = app ->
Conn.put_private(conn, :app, app)
_ ->
error = %Error{code: :not_found, details: %{app: "not found"}}
Renderer.send_error(conn, error)
end
end
defp app(path_info) do
path_info
|> List.last()
|> Config.app()
end
end