@@ -320,6 +320,10 @@ type Request struct {
320
320
// redirects.
321
321
Response * Response
322
322
323
+ // Pattern is saving the pattern string of the matching handler.
324
+ // This field is also available for third-party routers.
325
+ Pattern string
326
+
323
327
// ctx is either the client or server context. It should only
324
328
// be modified via copying the whole Request using Clone or WithContext.
325
329
// It is unexported to prevent people from using Context wrong
@@ -1561,39 +1565,3 @@ func (r *Request) requiresHTTP1() bool {
1561
1565
return hasToken (r .Header .Get ("Connection" ), "upgrade" ) &&
1562
1566
ascii .EqualFold (r .Header .Get ("Upgrade" ), "websocket" )
1563
1567
}
1564
-
1565
- // SetPattern parses a string into a Pattern and set in Request.
1566
- // The string's syntax is
1567
- //
1568
- // [METHOD] [HOST]/[PATH]
1569
- //
1570
- // where:
1571
- // - METHOD is an HTTP method
1572
- // - HOST is a hostname
1573
- // - PATH consists of slash-separated segments, where each segment is either
1574
- // a literal or a wildcard of the form "{name}", "{name...}", or "{$}".
1575
- //
1576
- // METHOD, HOST and PATH are all optional; that is, the string can be "/".
1577
- // If METHOD is present, it must be followed by at least one space or tab.
1578
- // Wildcard names must be valid Go identifiers.
1579
- // The "{$}" and "{name...}" wildcard must occur at the end of PATH.
1580
- // PATH may end with a '/'.
1581
- // Wildcard names in a path must be distinct.
1582
- func (r * Request ) SetPattern (s string ) error {
1583
- pat , err := parsePattern (s )
1584
- if err != nil {
1585
- return err
1586
- }
1587
- r .pat = pat
1588
- return nil
1589
- }
1590
-
1591
- // Pattern returns the pattern that matched this request, if the request
1592
- // resulted from matching a pattern registered on a ServeMux.
1593
- // Otherwise, it returns the empty string.
1594
- func (r * Request ) Pattern () string {
1595
- if r .pat == nil {
1596
- return ""
1597
- }
1598
- return r .pat .str
1599
- }
0 commit comments