From 9a9caf86ebd6b3ae36278a03404bfec89b610b28 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 17 Feb 2022 13:17:25 +0000 Subject: [PATCH] Docs --- clientapi/routing/routing.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go index 95b6bde74..c0cbad84a 100644 --- a/clientapi/routing/routing.go +++ b/clientapi/routing/routing.go @@ -117,6 +117,11 @@ func Setup( ).Methods(http.MethodGet, http.MethodPost, http.MethodOptions) } + // 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 + // (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 + // using ?: so the final regexp becomes what is below. v3mux := publicAPIMux.PathPrefix("/{version:(?:r0|v3)}/").Subrouter() unstableMux := publicAPIMux.PathPrefix("/unstable").Subrouter()