Skip to content

Commit

Permalink
Add @doc false and move public before private functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Schaefermeyer committed Oct 31, 2018
1 parent d4da794 commit 1ca97ed
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions lib/cors_plug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ defmodule CORSPlug do
]
end

@doc false
def call(conn, options) do
conn = merge_resp_headers(conn, headers(conn, options))

case {options[:send_preflight_response?], conn.method} do
{true, "OPTIONS"} -> conn |> send_resp(204, "") |> halt()
{_, _method} -> conn
end
end

@doc false
def init(options) do
options
|> prepare_cfg(Application.get_all_env(:cors_plug))
Expand All @@ -41,15 +52,6 @@ defmodule CORSPlug do
|> Keyword.merge(options)
end

def call(conn, options) do
conn = merge_resp_headers(conn, headers(conn, options))

case {options[:send_preflight_response?], conn.method} do
{true, "OPTIONS"} -> conn |> send_resp(204, "") |> halt()
{_, _method} -> conn
end
end

# headers specific to OPTIONS request
defp headers(conn = %Plug.Conn{method: "OPTIONS"}, options) do
headers(%{conn | method: nil}, options) ++
Expand Down

0 comments on commit 1ca97ed

Please sign in to comment.