mirror of https://github.com/gofiber/fiber.git
⚠ add warning message
parent
2d301ed7ce
commit
251a2e46e2
|
@ -1,13 +1,21 @@
|
|||
package timeout
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
var once sync.Once
|
||||
|
||||
// New wraps a handler and aborts the process of the handler if the timeout is reached
|
||||
func New(handler fiber.Handler, timeout time.Duration) fiber.Handler {
|
||||
once.Do(func() {
|
||||
fmt.Println("[Warning] timeout contains data race issues, not ready for production!")
|
||||
})
|
||||
|
||||
if timeout <= 0 {
|
||||
return handler
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue