ef4df58eadbbfb71ff25dde826e985f00b107f42 — Martin Angers 7 months ago 33e5c5b
validate rate limit
1 files changed, 8 insertions(+), 2 deletions(-)

M builder/builder.go
M builder/builder.go => builder/builder.go +8 -2
@@ 230,8 230,14 @@
 		mw = append(mw, timeoutHandler(route.Config.HandlerTimeout))
 	}
 
-	if route.Config.RequestLimit != nil {
-		// TODO: validate parms
+	if conf := route.Config.RequestLimit; conf != nil {
+		// either rate or fill interval must be set, not both.
+		if conf.FillInterval > 0 && conf.Rate > 0 {
+			return fmt.Errorf("handler: only one of FillInterval or Rate must be set")
+		}
+		if conf.FillInterval <= 0 && conf.Rate <= 0 {
+			return fmt.Errorf("handler: one of FillInterval or Rate must be set")
+		}
 		mw = append(mw, requestLimit(route.Config.RequestLimit))
 	}