34 lines
573 B
Go
Raw Normal View History

2016-11-20 10:26:11 +00:00
package main
import (
2017-05-29 22:07:05 +00:00
"strings"
2016-11-20 10:26:11 +00:00
2016-11-22 16:37:20 +00:00
"github.com/aerogo/aero"
2016-11-20 10:26:11 +00:00
)
2017-10-02 00:09:05 +00:00
// rewrite will rewrite certain routes
2019-06-01 04:55:49 +00:00
func rewrite(ctx aero.RewriteContext) {
requestURI := ctx.Path()
2017-10-01 22:31:44 +00:00
// User profiles
if strings.HasPrefix(requestURI, "/+") {
newURI := "/user/"
userName := requestURI[2:]
2019-06-01 04:55:49 +00:00
ctx.SetPath(newURI + userName)
2017-10-01 22:31:44 +00:00
return
}
if strings.HasPrefix(requestURI, "/_/+") {
newURI := "/_/user/"
userName := requestURI[4:]
2019-06-01 04:55:49 +00:00
ctx.SetPath(newURI + userName)
2017-10-01 22:31:44 +00:00
return
}
// Analytics
if requestURI == "/dark-flame-master" {
2019-06-01 04:55:49 +00:00
ctx.SetPath("/api/new/analytics")
2017-10-01 22:31:44 +00:00
return
}
2016-11-20 10:26:11 +00:00
}