rename ngin to rest
This commit is contained in:
18
rest/handler/timeouthandler.go
Normal file
18
rest/handler/timeouthandler.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
const reason = "Request Timeout"
|
||||
|
||||
func TimeoutHandler(duration time.Duration) func(http.Handler) http.Handler {
|
||||
return func(next http.Handler) http.Handler {
|
||||
if duration > 0 {
|
||||
return http.TimeoutHandler(next, duration, reason)
|
||||
} else {
|
||||
return next
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user