File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package main
22
33import (
44 "encoding/json"
5+ "fmt"
56 "net/http"
67 "time"
78
@@ -47,6 +48,7 @@ func (app *App) serverSubRouter(sr *mux.Router) {
4748 sr .Handle ("" , appHandler (app .trailingSlashRedirect ))
4849 sr .Handle ("/" , appHandler (app .secondLevelHandler ))
4950 s := sr .PathPrefix ("/meta-data" ).Subrouter ()
51+ s .Handle ("" , appHandler (app .trailingSlashRedirect ))
5052 s .Handle ("/" , appHandler (app .metaDataHandler ))
5153 s .Handle ("/instance-id" , appHandler (app .instanceIDHandler ))
5254 s .Handle ("/local-hostname" , appHandler (app .localHostnameHandler ))
@@ -155,7 +157,12 @@ func (app *App) securityCredentialsHandler(w http.ResponseWriter, r *http.Reques
155157}
156158
157159func (app * App ) trailingSlashRedirect (w http.ResponseWriter , r * http.Request ) {
158- w .Header ().Set ("Location" , r .URL .String ()+ "/" )
160+ location := ""
161+ if app .NoSchemeHostRedirects == false {
162+ location = "http://169.254.169.254"
163+ }
164+ location = fmt .Sprintf ("%s%s/" , location , r .URL .String ())
165+ w .Header ().Set ("Location" , location )
159166 w .WriteHeader (301 )
160167}
161168
You can’t perform that action at this time.
0 commit comments