@ -81,22 +81,26 @@ func setBrowserRedirectHandler(h http.Handler) http.Handler {
}
}
func ( h redirectHandler ) ServeHTTP ( w http . ResponseWriter , r * http . Request ) {
func ( h redirectHandler ) ServeHTTP ( w http . ResponseWriter , r * http . Request ) {
// Re-direction handled specifically for browsers.
aType := getRequestAuthType ( r )
if strings . Contains ( r . Header . Get ( "User-Agent" ) , "Mozilla" ) && ! isRequestSignatureV4 ( r ) {
// Re-direct only for JWT and anonymous requests coming from web-browser.
switch r . URL . Path {
if aType == authTypeJWT || aType == authTypeAnonymous {
case "/" , "/webrpc" , "/login" , "/favicon.ico" :
// Re-direction handled specifically for browsers.
// '/' is redirected to 'locationPrefix/'
if strings . Contains ( r . Header . Get ( "User-Agent" ) , "Mozilla" ) {
// '/webrpc' is redirected to 'locationPrefix/webrpc'
switch r . URL . Path {
// '/login' is redirected to 'locationPrefix/login'
case "/" , "/webrpc" , "/login" , "/favicon.ico" :
location := h . locationPrefix + r . URL . Path
// '/' is redirected to 'locationPrefix/'
// Redirect to new location.
// '/webrpc' is redirected to 'locationPrefix/webrpc'
http . Redirect ( w , r , location , http . StatusTemporaryRedirect )
// '/login' is redirected to 'locationPrefix/login'
return
location := h . locationPrefix + r . URL . Path
case h . locationPrefix :
// Redirect to new location.
// locationPrefix is redirected to 'locationPrefix/'
http . Redirect ( w , r , location , http . StatusTemporaryRedirect )
location := h . locationPrefix + "/"
return
http . Redirect ( w , r , location , http . StatusTemporaryRedirect )
case h . locationPrefix :
return
// locationPrefix is redirected to 'locationPrefix/'
location := h . locationPrefix + "/"
http . Redirect ( w , r , location , http . StatusTemporaryRedirect )
return
}
}
}
}
}
h . handler . ServeHTTP ( w , r )
h . handler . ServeHTTP ( w , r )