add logging for URL redirection in main.go
This commit is contained in:
3
main.go
3
main.go
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
"github.com/cloudwego/hertz/pkg/app/server"
|
||||
"github.com/cloudwego/hertz/pkg/common/hlog"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -31,7 +32,9 @@ func main() {
|
||||
}
|
||||
}
|
||||
}
|
||||
oldURL := scheme + "://" + host + string(c.Request.RequestURI())
|
||||
newURL := scheme + "://" + newHost + string(c.Request.RequestURI())
|
||||
hlog.Infof("Redirecting from %s to %s", oldURL, newURL)
|
||||
c.Redirect(301, []byte(newURL))
|
||||
c.Abort()
|
||||
return
|
||||
|
Reference in New Issue
Block a user