Skip to content

Commit f4e0ef1

Browse files
committed
fix: convert import Corsica to alias
makes external calls more visible for tracking changes to upstream code and future deprecations and breaking changes.
1 parent 0d03947 commit f4e0ef1

File tree

1 file changed

+8
-7
lines changed
  • apps/api_web/lib/api_web/plugs

1 file changed

+8
-7
lines changed

apps/api_web/lib/api_web/plugs/cors.ex

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ defmodule ApiWeb.Plugs.CORS do
44
"""
55

66
import Plug.Conn
7-
import Corsica
87
import Phoenix.Controller, only: [render: 3, put_view: 2]
98

10-
@default_opts sanitize_opts(
9+
alias Corsica
10+
11+
@default_opts Corsica.sanitize_opts(
1112
origins: "*",
1213
allow_methods: :all,
1314
allow_headers: [
@@ -21,16 +22,16 @@ defmodule ApiWeb.Plugs.CORS do
2122
def init(opts), do: opts
2223

2324
def call(%{assigns: assigns} = conn, _) do
24-
if cors_req?(conn) do
25+
if Corsica.cors_req?(conn) do
2526
allowed_domains = parse_allowed_domains(assigns.api_user.allowed_domains)
2627
opts = %{@default_opts | origins: allowed_domains}
2728

2829
cond do
29-
preflight_req?(conn) ->
30-
send_preflight_resp(conn, opts)
30+
Corsica.preflight_req?(conn) ->
31+
Corsica.send_preflight_resp(conn, opts)
3132

32-
allowed_origin?(conn, opts) ->
33-
put_cors_simple_resp_headers(conn, opts)
33+
Corsica.allowed_origin?(conn, opts) ->
34+
Corsica.put_cors_simple_resp_headers(conn, opts)
3435

3536
true ->
3637
render_400(conn)

0 commit comments

Comments
 (0)