Skip to content

Commit 214343e

Browse files
committed
Enhance routing capabilities by adding support for the query HTTP verb. Update documentation and tests to reflect this new feature. Also, include a new entry in the CHANGELOG for version 1.8.9.
1 parent 9d3f1f6 commit 214343e

6 files changed

Lines changed: 19 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ This release introduces deprecation warnings for several features that have been
2929

3030
* The `config` variable is no longer available in `Phoenix.Endpoint`. In the past, it was possible to read your endpoint configuration at compile-time via an injected variable named `config`, which is no longer supported. Use `Application.compile_env/3` instead, which is tracked by the Elixir compiler and lead to a better developer experience. This may also lead to errors on application boot if you were previously incorrectly setting compile time config at runtime.
3131

32+
## 1.9.0
33+
34+
This release requires Plug v1.21+.
35+
36+
### Enhancements
37+
- [Router] Add the `query` macro for routing HTTP QUERY (RFC 10008) requests ([#6737](https://github.com/phoenixframework/phoenix/pull/6737))
38+
3239
## 1.8.8 (2026-06-10)
3340

3441
### Enhancements

guides/routing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Inside the scope block, however, we have our first actual route:
5656
get "/", PageController, :home
5757
```
5858

59-
`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.
59+
`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.
6060

6161
> #### Why the macros? {: .info}
6262
>

lib/phoenix/router.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ defmodule Phoenix.Router do
282282

283283
alias Phoenix.Router.{Resource, Scope, Route, Helpers}
284284

285-
@http_methods [:get, :post, :put, :patch, :delete, :options, :connect, :trace, :head]
285+
@http_methods [:get, :query, :post, :put, :patch, :delete, :options, :connect, :trace, :head]
286286

287287
@doc false
288288
defmacro __using__(opts) do

lib/phoenix/test/conn_test.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ defmodule Phoenix.ConnTest do
154154
|> Conn.put_private(:phoenix_recycled, true)
155155
end
156156

157-
@http_methods [:get, :post, :put, :patch, :delete, :options, :connect, :trace, :head]
157+
@http_methods [:get, :query, :post, :put, :patch, :delete, :options, :connect, :trace, :head]
158158

159159
for method <- @http_methods do
160160
@doc """

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ defmodule Phoenix.MixProject do
7979

8080
defp deps do
8181
[
82-
{:plug, "~> 1.14"},
82+
{:plug, "~> 1.21"},
8383
{:plug_crypto, "~> 1.2 or ~> 2.0"},
8484
{:telemetry, "~> 0.4 or ~> 1.0"},
8585
{:phoenix_pubsub, "~> 2.1"},

test/phoenix/router/routing_test.exs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ defmodule Phoenix.Router.RoutingTest do
1717
def options(conn, _params), do: text(conn, "users options")
1818
def connect(conn, _params), do: text(conn, "users connect")
1919
def trace(conn, _params), do: text(conn, "users trace")
20+
def query(conn, _params), do: text(conn, "users query")
2021
def not_found(conn, _params), do: text(put_status(conn, :not_found), "not found")
2122
def image(conn, _params), do: text(conn, conn.params["path"] || "show files")
2223
def move(conn, _params), do: text(conn, "users move")
@@ -56,6 +57,7 @@ defmodule Phoenix.Router.RoutingTest do
5657
trace("/trace", UserController, :trace)
5758
options "/options", UserController, :options
5859
connect "/connect", UserController, :connect
60+
query "/query", UserController, :query
5961
match :move, "/move", UserController, :move
6062
match :*, "/any", UserController, :any
6163

@@ -185,6 +187,12 @@ defmodule Phoenix.Router.RoutingTest do
185187
assert conn.resp_body == "users trace"
186188
end
187189

190+
test "query to custom action" do
191+
conn = call(Router, :query, "/query")
192+
assert conn.status == 200
193+
assert conn.resp_body == "users query"
194+
end
195+
188196
test "splat arg with preceding named parameter to files/:user_name/*path" do
189197
conn = call(Router, :get, "/files/elixir/Users/home/file.txt")
190198
assert conn.status == 200

0 commit comments

Comments
 (0)