From 1129a85058919968103d85a127180d6b47c3029f Mon Sep 17 00:00:00 2001 From: Fenny <25108519+Fenny@users.noreply.github.com> Date: Sat, 4 Jul 2020 09:55:01 +0200 Subject: [PATCH] Update timeout.go Co-Authored-By: kiyon --- middleware/timeout.go | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/middleware/timeout.go b/middleware/timeout.go index 32669234..b7cfdfe2 100644 --- a/middleware/timeout.go +++ b/middleware/timeout.go @@ -8,29 +8,6 @@ import ( // Timeout wraps a handler and aborts the process of the handler if the timeout is reached func Timeout(handler fiber.Handler, timeout time.Duration) fiber.Handler { - // fHandler := func(fctx *fasthttp.RequestCtx) { - // // Emulate long-running task, which touches ctx. - // doneCh := make(chan struct{}) - // go func() { - // workDuration := time.Millisecond * time.Duration(rand.Intn(2000)) - // time.Sleep(workDuration) - - // fmt.Fprintf(fctx, "ctx has been accessed by long-running task\n") - // fmt.Fprintf(fctx, "The reuqestHandler may be finished by this time.\n") - - // close(doneCh) - // }() - - // select { - // case <-doneCh: - // case <-time.After(timeout): - // fctx.TimeoutError("Timeout!") - // } - // } - // return func(ctx *fiber.Ctx) { - // fHandler(ctx.Fasthttp) - // } - if timeout <= 0 { return handler }