Added cover image support for the beta

This commit is contained in:
2016-11-20 19:26:11 +09:00
parent c89add3967
commit 614ff87246
16 changed files with 316 additions and 23 deletions

29
rewrite.go Normal file
View File

@ -0,0 +1,29 @@
package main
import (
"bytes"
"github.com/valyala/fasthttp"
)
func init() {
plusRoute := []byte("/+")
plusRouteAjax := []byte("/_/+")
// This will rewrite /+UserName requests to /user/UserName
app.Rewrite(func(ctx *fasthttp.RequestCtx) {
requestURI := ctx.RequestURI()
if bytes.HasPrefix(requestURI, plusRoute) {
newURI := []byte("/user/")
userName := requestURI[2:]
newURI = append(newURI, userName...)
ctx.Request.SetRequestURIBytes(newURI)
} else if bytes.HasPrefix(requestURI, plusRouteAjax) {
newURI := []byte("/_/user/")
userName := requestURI[4:]
newURI = append(newURI, userName...)
ctx.Request.SetRequestURIBytes(newURI)
}
})
}