diff options
| author | Jonathan Amsterdam <jba@google.com> | 2023-12-18 13:07:07 -0500 |
|---|---|---|
| committer | Jonathan Amsterdam <jba@google.com> | 2023-12-19 11:08:11 +0000 |
| commit | 1d4b0b6236febe0646d8d7b0103da5d169f185cc (patch) | |
| tree | 57743267a54a7bcb75167af240d2997a6e26b3fd | |
| parent | 6fe0d3758b35afcc342832e376d8d985a5a29070 (diff) | |
| download | go-1d4b0b6236febe0646d8d7b0103da5d169f185cc.tar.xz | |
doc/go1.22.html: release notes for slog, testing/slogtest and net/http.ServeMux
Updates #61422.
Change-Id: I8f2dfe92405f409c46465bbb5714eff662ce9b49
Reviewed-on: https://go-review.googlesource.com/c/go/+/550776
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
| -rw-r--r-- | doc/go1.22.html | 61 |
1 files changed, 46 insertions, 15 deletions
diff --git a/doc/go1.22.html b/doc/go1.22.html index 458e17954d..c2bcef3053 100644 --- a/doc/go1.22.html +++ b/doc/go1.22.html @@ -359,6 +359,45 @@ and the Go runtime also use ChaCha8 for randomness. We plan to include an API migration tool in a future release, likely Go 1.23. </p> +<h3 id="enhanced_routing_patterns"</h3> + +<p><!-- https://go.dev/issue/61410 --> + HTTP routing in the standard library is now more expressive. + The patterns used by <a href="/pkg/net/http#ServeMux"><code>net/http.ServeMux</code></a> have been enhanced to accept methods and wildcards. +</p> + +<p> + Registering a handler with a method, like <code>"POST /items/create"</code>, restricts + invocations of the handler to requests with the given method. A pattern with a method takes precedence over a matching pattern without one. + As a special case, registering a handler with <code> "GET"</code> also registers it with <code>"HEAD"</code>. +</p> + +<p> + Wildcards in patterns, like <code>/items/{id}</code>, match segments of the URL path. + The actual segment value may be accessed by calling the <a href="/pkg/net/http#Request.PathValue"><code>Request.PathValue</code></a> method. + A wildcard ending in "...", like <code>/files/{path...}</code>, must occur at the end of a pattern and matches all the remaining segments. +</p> + +<p> + A pattern that ends in "/" matches all paths that have it as a prefix, as always. + To match the exact pattern including the trailing slash, end it with <code>{$}</code>, + as in <code>/exact/match/{$}</code>. +</p> + +<p> + If two patterns overlap in the requests that they match, then the more specific pattern takes precedence. + If neither is more specific, the patterns conflict. + This rule generalizes the original precedence rules and maintains the property that the order in which + patterns are registered does not matter. +</p> + +<p> + This change breaks backwards compatiblity in small ways, some obvious—patterns with "{" and "}" behave differently— + and some less so—treatment of escaped paths has been improved. + The change is controlled by a <a href="/doc/godebug"><code>GODEBUG</code></a> field named <code>httpmuxgo121</code>. + Set <code>httpmuxgo121=1</code> to restore the old behavior. +</p> + <h3 id="minor_library_changes">Minor changes to the library</h3> <p> @@ -633,14 +672,13 @@ We plan to include an API migration tool in a future release, likely Go 1.23. <dl id="log/slog"><dt><a href="/pkg/log/slog/">log/slog</a></dt> <dd> <p><!-- https://go.dev/issue/62418 --> - TODO: <a href="https://go.dev/issue/62418">https://go.dev/issue/62418</a>: enable setting level on default log.Logger - </p> - - <p><!-- CL 525096 --> - TODO: <a href="https://go.dev/cl/525096">https://go.dev/cl/525096</a>: log/slog: add LogLoggerLevel to enable setting level on the default logger; modified api/next/62418.txt + The new <a href="/pkg/log/slog#SetLogLoggerLevel"><code>SetLogLoggerLevel</code></a> function + controls the level for the bridge between the `slog` and `log` packages. It sets the minimum level + for calls to the top-level `slog` logging functions, and it sets the level for calls to `log.Logger` + that go through `slog`. </p> </dd> -</dl><!-- log/slog --> +</dl> <dl id="math/big"><dt><a href="/pkg/math/big/">math/big</a></dt> <dd> @@ -682,10 +720,6 @@ We plan to include an API migration tool in a future release, likely Go 1.23. operating on an <code>fs.FS</code>. </p> - <p><!-- https://go.dev/issue/61410 --> - TODO: <a href="https://go.dev/issue/61410">https://go.dev/issue/61410</a>: enhanced ServeMux routing - </p> - <p><!-- https://go.dev/issue/61679 --> The HTTP server and client now reject requests and responses containing an invalid empty <code>Content-Length</code> header. @@ -925,11 +959,8 @@ We plan to include an API migration tool in a future release, likely Go 1.23. <dl id="testing/slogtest"><dt><a href="/pkg/testing/slogtest/">testing/slogtest</a></dt> <dd> <p><!-- https://go.dev/issue/61758 --> - TODO: <a href="https://go.dev/issue/61758">https://go.dev/issue/61758</a>: support sub-tests - </p> - - <p><!-- CL 516076 --> - TODO: <a href="https://go.dev/cl/516076">https://go.dev/cl/516076</a>: testing/slogtest: add Run to run cases as subtests; modified api/next/61758.txt + The new <a href="/pkg/testing/slogtest#Run"><code>Run</code></a> function uses sub-tests to run test cases, + providing finer-grained control. </p> </dd> </dl><!-- testing/slogtest --> |
