diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cef2128da..5fd491174e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog for v1.9 +This release requires Plug v1.21+. + ## Enhancements * The longpoll session token is now sent in a `x-phoenix-longpoll-token` @@ -7,6 +9,8 @@ old and new nodes are active at the same time, ensure that you deploy Phoenix v1.8.10 or a later v1.8 release first. + * [Router] Add the `query` macro for routing HTTP QUERY (RFC 10008) requests ([#6737](https://github.com/phoenixframework/phoenix/pull/6737)) + ## v1.8 The CHANGELOG for v1.8 releases can be found in the [v1.8 branch](https://github.com/phoenixframework/phoenix/blob/v1.8/CHANGELOG.md). diff --git a/guides/routing.md b/guides/routing.md index b7efc0b24f..3486321253 100644 --- a/guides/routing.md +++ b/guides/routing.md @@ -56,7 +56,7 @@ Inside the scope block, however, we have our first actual route: get "/", PageController, :home ``` -`get` is a Phoenix macro that corresponds to the HTTP verb GET. Similar macros exist for other HTTP verbs, including POST, PUT, PATCH, DELETE, OPTIONS, CONNECT, TRACE, and HEAD. +`get` is a Phoenix macro that corresponds to the HTTP verb GET. Similar macros exist for other HTTP verbs, including QUERY, POST, PUT, PATCH, DELETE, OPTIONS, CONNECT, TRACE, and HEAD. > #### Why the macros? {: .info} > diff --git a/lib/phoenix/router.ex b/lib/phoenix/router.ex index 4a2c10279d..6a9f86c1dd 100644 --- a/lib/phoenix/router.ex +++ b/lib/phoenix/router.ex @@ -292,7 +292,7 @@ defmodule Phoenix.Router do alias Phoenix.Router.{Resource, Scope, Route, Helpers} - @http_methods [:get, :post, :put, :patch, :delete, :options, :connect, :trace, :head] + @http_methods [:get, :query, :post, :put, :patch, :delete, :options, :connect, :trace, :head] @doc false defmacro __using__(opts) do diff --git a/lib/phoenix/test/conn_test.ex b/lib/phoenix/test/conn_test.ex index 9def147398..466c9d4298 100644 --- a/lib/phoenix/test/conn_test.ex +++ b/lib/phoenix/test/conn_test.ex @@ -154,7 +154,7 @@ defmodule Phoenix.ConnTest do |> Conn.put_private(:phoenix_recycled, true) end - @http_methods [:get, :post, :put, :patch, :delete, :options, :connect, :trace, :head] + @http_methods [:get, :query, :post, :put, :patch, :delete, :options, :connect, :trace, :head] for method <- @http_methods do @doc """ diff --git a/mix.exs b/mix.exs index 4784be105c..1dd60a3173 100644 --- a/mix.exs +++ b/mix.exs @@ -79,7 +79,7 @@ defmodule Phoenix.MixProject do defp deps do [ - {:plug, "~> 1.14"}, + {:plug, "~> 1.21"}, {:plug_crypto, "~> 2.2"}, {:telemetry, "~> 0.4 or ~> 1.0"}, {:phoenix_pubsub, "~> 2.1"}, diff --git a/test/phoenix/router/routing_test.exs b/test/phoenix/router/routing_test.exs index 0818d40ab8..fdc1880618 100644 --- a/test/phoenix/router/routing_test.exs +++ b/test/phoenix/router/routing_test.exs @@ -17,6 +17,7 @@ defmodule Phoenix.Router.RoutingTest do def options(conn, _params), do: text(conn, "users options") def connect(conn, _params), do: text(conn, "users connect") def trace(conn, _params), do: text(conn, "users trace") + def query(conn, _params), do: text(conn, "users query") def not_found(conn, _params), do: text(put_status(conn, :not_found), "not found") def image(conn, _params), do: text(conn, conn.params["path"] || "show files") def move(conn, _params), do: text(conn, "users move") @@ -56,6 +57,7 @@ defmodule Phoenix.Router.RoutingTest do trace("/trace", UserController, :trace) options "/options", UserController, :options connect "/connect", UserController, :connect + query "/query", UserController, :query match :move, "/move", UserController, :move match :*, "/any", UserController, :any @@ -185,6 +187,12 @@ defmodule Phoenix.Router.RoutingTest do assert conn.resp_body == "users trace" end + test "query to custom action" do + conn = call(Router, :query, "/query") + assert conn.status == 200 + assert conn.resp_body == "users query" + end + test "splat arg with preceding named parameter to files/:user_name/*path" do conn = call(Router, :get, "/files/elixir/Users/home/file.txt") assert conn.status == 200