Switched to net/http

This commit is contained in:
Eduard Urbach 2017-05-30 00:07:05 +02:00
parent b04497649a
commit 08f64b3909
2 changed files with 14 additions and 13 deletions

5
.gitignore vendored
View File

@ -41,4 +41,7 @@ debug
/notify.moe
# DB
/db
/db
# Cert
/security

View File

@ -1,29 +1,27 @@
package main
import (
"bytes"
"strings"
"github.com/aerogo/aero"
)
func init() {
plusRoute := []byte("/+")
plusRouteAjax := []byte("/_/+")
plusRoute := "/+"
plusRouteAjax := "/_/+"
// This will rewrite /+UserName requests to /user/UserName
app.Rewrite(func(ctx *aero.RewriteContext) {
requestURI := ctx.URIBytes()
requestURI := ctx.URI()
if bytes.HasPrefix(requestURI, plusRoute) {
newURI := []byte("/user/")
if strings.HasPrefix(requestURI, plusRoute) {
newURI := "/user/"
userName := requestURI[2:]
newURI = append(newURI, userName...)
ctx.SetURIBytes(newURI)
} else if bytes.HasPrefix(requestURI, plusRouteAjax) {
newURI := []byte("/_/user/")
ctx.SetURI(newURI + userName)
} else if strings.HasPrefix(requestURI, plusRouteAjax) {
newURI := "/_/user/"
userName := requestURI[4:]
newURI = append(newURI, userName...)
ctx.SetURIBytes(newURI)
ctx.SetURI(newURI + userName)
}
})
}