diff --git a/routes/routes.go b/routes/routes.go index bb98f71..dfedf30 100644 --- a/routes/routes.go +++ b/routes/routes.go @@ -41,7 +41,6 @@ func GetRoutes() []Route { "/b(ase)?64(/(?P.*))?": handleDecodeBase64, "/bytes(/(?P.+))?": handleRandomBytes, - "/delay/(?P[^/]+)": handleDelayedResponse, "/drip(-(?Plines))?(?P/.*)?": handleDrip, "/links/(?P\\d+)(/(?P\\d+))?/?": handleLinks, "/range/(?P\\d+)/?": handleRange, @@ -56,6 +55,8 @@ func GetRoutes() []Route { `(/(index\.html)?)?`: handleIndex, + "/delay/(?P[^/]+)": handleDelayedResponse, + "/payload": handlePayload, "/status/(?P[\\w,]+)": handleStatus, @@ -201,20 +202,19 @@ func handleRandomBytes(ex *exchange.Exchange) { ex.WriteBytes(util.RandomBytes(n)) } -func handleDelayedResponse(ex *exchange.Exchange) { +func handleDelayedResponse(ex *exchange.Exchange) response.Response { n, err := strconv.ParseFloat(ex.Field("delay"), 32) if err != nil { - ex.RespondBadRequest("Invalid delay: " + err.Error()) - return + return response.BadRequest("Invalid delay: " + err.Error()) } if n < 0 || n > 300 { - ex.RespondBadRequest("Delay can't be greater than 300 or less than 0") - return + return response.BadRequest("Delay can't be greater than 300 or less than 0") } time.Sleep(time.Duration(n * float64(time.Second))) + return response.New(http.StatusOK, nil, []byte("OK")) } func handleDrip(ex *exchange.Exchange) {