Limit incoming request body size for all endpoints and add rate limiting wrappera round storage

This commit is contained in:
breel
2020-07-26 20:25:39 -06:00
parent c3b948556c
commit 36c4ae520d
6 changed files with 86 additions and 5 deletions

View File

@@ -17,6 +17,7 @@ type Config struct {
Auth bool
AuthLifetime time.Duration
MaxFileSize int64
RPS int
}
func New() Config {
@@ -37,6 +38,7 @@ func New() Config {
as.Append(args.BOOL, "auth", "check for authorized access", false)
as.Append(args.DURATION, "authlifetime", "duration auth is valid for", time.Hour)
as.Append(args.INT, "max-file-size", "max file size for uploads in bytes", 50*(1<<20))
as.Append(args.INT, "rps", "rps per namespace", 5)
if err := as.Parse(); err != nil {
os.Remove(f.Name())
@@ -53,5 +55,6 @@ func New() Config {
Auth: as.GetBool("auth"),
AuthLifetime: as.GetDuration("authlifetime"),
MaxFileSize: int64(as.GetInt("max-file-size")),
RPS: as.GetInt("rps"),
}
}