Update routing.go

This commit is contained in:
Neil Alexander 2022-02-17 17:15:22 +00:00 committed by GitHub
parent 91d4336e47
commit a5d0b97fc9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -118,7 +118,7 @@ func Setup(
} }
// You can't just do PathPrefix("/(r0|v3)") because regexps only apply when inside named path variables. // You can't just do PathPrefix("/(r0|v3)") because regexps only apply when inside named path variables.
// So make a named path variable called 'version' (which we will never read in handlers) and then do // So make a named path variable called 'apiversion' (which we will never read in handlers) and then do
// (r0|v3) - BUT this is a captured group, which makes no sense because you cannot extract this group // (r0|v3) - BUT this is a captured group, which makes no sense because you cannot extract this group
// from a match (gorilla/mux exposes no way to do this) so it demands you make it a non-capturing group // from a match (gorilla/mux exposes no way to do this) so it demands you make it a non-capturing group
// using ?: so the final regexp becomes what is below. We also need a trailing slash to stop 'v33333' matching. // using ?: so the final regexp becomes what is below. We also need a trailing slash to stop 'v33333' matching.