You've already forked nyx
mirror of
https://github.com/rls-moe/nyx
synced 2025-08-19 06:18:38 +00:00
Improved stability, improved spam algorithm, fixed some bugs
This commit is contained in:
15
http/middle/limitsize.go
Normal file
15
http/middle/limitsize.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package middle
|
||||
|
||||
import (
|
||||
"go.rls.moe/nyx/config"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func LimitSize(c *config.Config) func(http.Handler) http.Handler {
|
||||
return func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
r.Body = http.MaxBytesReader(w, r.Body, 10*1024*1024)
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
}
|
@@ -13,3 +13,26 @@ func init() {
|
||||
func GetSession(r *http.Request) session.Session {
|
||||
return session.Get(r)
|
||||
}
|
||||
|
||||
func IsAdminSession(sess session.Session) bool {
|
||||
if sess == nil {
|
||||
return false
|
||||
}
|
||||
if sess.CAttr("mode") == "admin" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func IsModSession(sess session.Session) bool {
|
||||
if sess == nil {
|
||||
return false
|
||||
}
|
||||
if IsAdminSession(sess) {
|
||||
return true
|
||||
}
|
||||
if sess.CAttr("mode") == "mod" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Reference in New Issue
Block a user