From 8508ec939ae08fd8b8fe9bfbc537106b4429d4eb Mon Sep 17 00:00:00 2001 From: Jonathan Amsterdam Date: Mon, 18 Dec 2023 13:07:07 -0500 Subject: [PATCH] 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 Reviewed-by: Damien Neil TryBot-Result: Gopher Robot --- doc/go1.22.html | 61 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 15 deletions(-) diff --git a/doc/go1.22.html b/doc/go1.22.html index 458e17954de112..c2bcef30533c20 100644 --- a/doc/go1.22.html +++ b/doc/go1.22.html @@ -359,6 +359,45 @@

New math/rand/v2 package

We plan to include an API migration tool in a future release, likely Go 1.23.

+

+ +

+ HTTP routing in the standard library is now more expressive. + The patterns used by net/http.ServeMux have been enhanced to accept methods and wildcards. +

+ +

+ Registering a handler with a method, like "POST /items/create", 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 "GET" also registers it with "HEAD". +

+ +

+ Wildcards in patterns, like /items/{id}, match segments of the URL path. + The actual segment value may be accessed by calling the Request.PathValue method. + A wildcard ending in "...", like /files/{path...}, must occur at the end of a pattern and matches all the remaining segments. +

+ +

+ 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 {$}, + as in /exact/match/{$}. +

+ +

+ 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. +

+ +

+ 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 GODEBUG field named httpmuxgo121. + Set httpmuxgo121=1 to restore the old behavior. +

+

Minor changes to the library

@@ -633,14 +672,13 @@

Minor changes to the library

log/slog

- TODO: https://go.dev/issue/62418: enable setting level on default log.Logger -

- -

- TODO: https://go.dev/cl/525096: log/slog: add LogLoggerLevel to enable setting level on the default logger; modified api/next/62418.txt + The new SetLogLoggerLevel 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`.

-
+
math/big
@@ -682,10 +720,6 @@

Minor changes to the library

operating on an fs.FS.

-

- TODO: https://go.dev/issue/61410: enhanced ServeMux routing -

-

The HTTP server and client now reject requests and responses containing an invalid empty Content-Length header. @@ -925,11 +959,8 @@

Minor changes to the library

testing/slogtest

- TODO: https://go.dev/issue/61758: support sub-tests -

- -

- TODO: https://go.dev/cl/516076: testing/slogtest: add Run to run cases as subtests; modified api/next/61758.txt + The new Run function uses sub-tests to run test cases, + providing finer-grained control.