* Go 1.22 net/http mux patterns: `mux.HandleFunc("GET /users/{id}", h)`. * Returns the HTTP method when the pattern starts with one, null otherwise. * Only Handle/HandleFunc take these — Gin/Chi verb methods take a bare path.
(routePath: string, rawMethod: string)
| 173 | * Only Handle/HandleFunc take these — Gin/Chi verb methods take a bare path. |
| 174 | */ |
| 175 | function matchGo122MethodPattern(routePath: string, rawMethod: string): string | null { |
| 176 | if (rawMethod !== 'Handle' && rawMethod !== 'HandleFunc') return null; |
| 177 | const m = routePath.match(/^(GET|POST|PUT|PATCH|DELETE|OPTIONS|HEAD|CONNECT|TRACE)\s+\S/); |
| 178 | return m ? m[1]! : null; |
| 179 | } |
| 180 | |
| 181 | /** Extract the last identifier from an expression like `pkg.Sub.handler` or `handler`. */ |
| 182 | function extractGoTailIdent(expr: string): string | null { |