Switched to net/http
This commit is contained in:
parent
b04497649a
commit
08f64b3909
3
.gitignore
vendored
3
.gitignore
vendored
@ -42,3 +42,6 @@ debug
|
|||||||
|
|
||||||
# DB
|
# DB
|
||||||
/db
|
/db
|
||||||
|
|
||||||
|
# Cert
|
||||||
|
/security
|
22
rewrite.go
22
rewrite.go
@ -1,29 +1,27 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"strings"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
plusRoute := []byte("/+")
|
plusRoute := "/+"
|
||||||
plusRouteAjax := []byte("/_/+")
|
plusRouteAjax := "/_/+"
|
||||||
|
|
||||||
// This will rewrite /+UserName requests to /user/UserName
|
// This will rewrite /+UserName requests to /user/UserName
|
||||||
app.Rewrite(func(ctx *aero.RewriteContext) {
|
app.Rewrite(func(ctx *aero.RewriteContext) {
|
||||||
requestURI := ctx.URIBytes()
|
requestURI := ctx.URI()
|
||||||
|
|
||||||
if bytes.HasPrefix(requestURI, plusRoute) {
|
if strings.HasPrefix(requestURI, plusRoute) {
|
||||||
newURI := []byte("/user/")
|
newURI := "/user/"
|
||||||
userName := requestURI[2:]
|
userName := requestURI[2:]
|
||||||
newURI = append(newURI, userName...)
|
ctx.SetURI(newURI + userName)
|
||||||
ctx.SetURIBytes(newURI)
|
} else if strings.HasPrefix(requestURI, plusRouteAjax) {
|
||||||
} else if bytes.HasPrefix(requestURI, plusRouteAjax) {
|
newURI := "/_/user/"
|
||||||
newURI := []byte("/_/user/")
|
|
||||||
userName := requestURI[4:]
|
userName := requestURI[4:]
|
||||||
newURI = append(newURI, userName...)
|
ctx.SetURI(newURI + userName)
|
||||||
ctx.SetURIBytes(newURI)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user