Repository: phoenixframework/phoenix
Pull request #3769 (2020-04-17 23:20:05)

Clarify the new tds adapter
There are the older thrid-party adapters and the new one built-in to `ecto_sql`. 
Clarify which one is used in phoenix and provide a link for users to explore more.


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4309bd94e..b575c820c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -39,7 +39,7 @@ Phoenix built-in guides have been restructured and revamped, providing a better
 
 ### phx.new installer
 
-  * Built-in support for MSSQL databases via the `tds` adapter
+  * Built-in support for MSSQL databases via [`Ecto.Adapters.Tds`](https://hexdocs.pm/ecto_sql/Ecto.Adapters.Tds.html)
   * `Phoenix.PubSub` is now started directly in your application supervision tree
   * `Phoenix.Ecto.CheckRepoStatus` is now added to new applications that use Ecto
   * Automatically use `System.get_env("MIX_TEST_PARTITION")` in the database name in the test environment for built-in CI test partitioning
diff --git a/lib/phoenix/endpoint.ex b/lib/phoenix/endpoint.ex
index 489fea3c0..25104f210 100644
--- a/lib/phoenix/endpoint.ex
+++ b/lib/phoenix/endpoint.ex
@@ -290,6 +290,16 @@ defmodule Phoenix.Endpoint do
   """
   @callback static_lookup(path :: String.t) :: {String.t, String.t} | {String.t, nil}
 
+  @doc """
+  Returns the script name from the :url configuration.
+  """
+  @callback script_name() :: [String.t]
+
+  @doc """
+  Returns the host from the :url configuration.
+  """
+  @callback host() :: String.t
+
   # Channels
 
   @doc """
diff --git a/lib/phoenix/endpoint/supervisor.ex b/lib/phoenix/endpoint/supervisor.ex
index 59b5d8649..00ae023cc 100644
--- a/lib/phoenix/endpoint/supervisor.ex
+++ b/lib/phoenix/endpoint/supervisor.ex
@@ -410,9 +410,9 @@ defmodule Phoenix.Endpoint.Supervisor do
   Invoked to warm up caches on start and config change.
   """
   def warmup(endpoint) do
-    endpoint.host
+    endpoint.host()
+    endpoint.script_name()
     endpoint.path("/")
-    endpoint.script_name
     warmup_url(endpoint)
     warmup_static(endpoint)
     :ok
diff --git a/lib/phoenix/router.ex b/lib/phoenix/router.ex
index 3e76b7444..727dedd0c 100644
--- a/lib/phoenix/router.ex
+++ b/lib/phoenix/router.ex
@@ -954,6 +954,8 @@ defmodule Phoenix.Router do
   @doc """
   Returns the compile-time route info and runtime path params for a request.
 
+  The `path` can be either a string or the `path_info` segments.
+
   A map of metadata is returned with the following keys:
 
     * `:log` - the configured log level. For example `:debug`
@@ -978,8 +980,12 @@ defmodule Phoenix.Router do
       iex> Phoenix.Router.route_info(MyRouter, "GET", "/not-exists", "myhost")
       :error
   """
-  def route_info(router, method, path, host) do
+  def route_info(router, method, path, host) when is_binary(path) do
     split_path = for segment <- String.split(path, "/"), segment != "", do: segment
+    route_info(router, method, split_path, host)
+  end
+
+  def route_info(router, method, split_path, host) when is_list(split_path) do
     case router.__match_route__(method, split_path, host) do
       {%{} = metadata, _prepare, _pipeline, {_plug, _opts}} -> Map.delete(metadata, :conn)
       :error -> :error


Test patch:
diff --git a/test/phoenix/router/routing_test.exs b/test/phoenix/router/routing_test.exs
index 2bd1aa766..93e3af42c 100644
--- a/test/phoenix/router/routing_test.exs
+++ b/test/phoenix/router/routing_test.exs
@@ -254,4 +254,15 @@ defmodule Phoenix.Router.RoutingTest do
 
     assert Phoenix.Router.route_info(Router, "POST", "/not-exists", "host") == :error
   end
+
+  test "route_info returns route string, path params and more for split path" do
+    assert Phoenix.Router.route_info(Router, "GET", ~w(foo bar baz), nil) == %{
+             log: :debug,
+             path_params: %{"path" => ["foo", "bar", "baz"]},
+             pipe_through: [],
+             plug: Phoenix.Router.RoutingTest.UserController,
+             plug_opts: :not_found,
+             route: "/*path"
+           }
+  end
 end