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 /notify.moe
# DB # DB
/db /db
# Cert
/security

View File

@ -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)
} }
}) })
} }