@@ -48,23 +48,19 @@ func NewBucketUI(logger log.Logger, label, externalPrefix, prefixHeader, uiPrefi
48
48
}
49
49
50
50
// Register registers http routes for bucket UI.
51
- func (b * Bucket ) Register (r * route.Router , registerNewUI bool , ins extpromhttp.InstrumentationMiddleware ) {
52
- instrf := func (name string , next func (w http.ResponseWriter , r * http.Request )) http.HandlerFunc {
53
- return ins .NewHandler (b .externalPrefix + name , http .HandlerFunc (next ))
54
- }
55
- r .WithPrefix (b .uiPrefix ).Get ("/" , instrf ("root" , b .root ))
56
- r .WithPrefix (b .uiPrefix ).Get ("/static/*filepath" , instrf ("static" , b .serveStaticAsset ))
57
- if registerNewUI {
58
- // Make sure that "<path-prefix>/new" is redirected to "<path-prefix>/new/" and
59
- // not just the naked "/new/", which would be the default behavior of the router
60
- // with the "RedirectTrailingSlash" option (https://godoc.org/github.com/julienschmidt/httprouter#Router.RedirectTrailingSlash),
61
- // and which breaks users with a --web.route-prefix that deviates from the path derived
62
- // from the external URL.
63
- r .Get ("/new" , func (w http.ResponseWriter , r * http.Request ) {
64
- http .Redirect (w , r , path .Join (GetWebPrefix (b .logger , b .externalPrefix , b .prefixHeader , r ), "new" )+ "/" , http .StatusFound )
65
- })
66
- r .Get ("/new/*filepath" , instrf ("react-static" , b .serveReactUI ))
67
- }
51
+ func (b * Bucket ) Register (r * route.Router , ins extpromhttp.InstrumentationMiddleware ) {
52
+ r .Get ("/" , func (w http.ResponseWriter , r * http.Request ) {
53
+ http .Redirect (w , r , path .Join (GetWebPrefix (b .logger , b .externalPrefix , b .prefixHeader , r ), "/blocks" ), http .StatusFound )
54
+ })
55
+ // Redirect the original React UI's path (under "/new") to its new path at the root.
56
+ r .Get ("/new/*path" , func (w http.ResponseWriter , r * http.Request ) {
57
+ p := route .Param (r .Context (), "path" )
58
+ http .Redirect (w , r , path .Join (GetWebPrefix (b .logger , b .externalPrefix , b .prefixHeader , r ), strings .TrimPrefix (p , "/new" ))+ "?" + r .URL .RawQuery , http .StatusFound )
59
+ })
60
+
61
+ r .WithPrefix (b .uiPrefix ).Get ("/classic" , instrf ("root" , ins , b .root ))
62
+ r .WithPrefix (b .uiPrefix ).Get ("/classic/static/*filepath" , instrf ("static" , ins , b .serveStaticAsset ))
63
+ registerReactApp (r , ins , b .BaseUI )
68
64
}
69
65
70
66
// Handle / of bucket UIs.
0 commit comments