Golang net/http.TimeoutHandler() function example

package net/http

Golang net/http.TimeoutHandler() function usage example

 package main

 import (
 "net/http"
 "time"
 )

 func main() {

 h := http.FileServer(http.Dir("/tmp")) 

 dt := 2 * time.Second

 http.ListenAndServe(":8080", http.TimeoutHandler(h, dt, "file scanning timed out!"))
 }

Reference :

http://golang.org/pkg/net/http/#TimeoutHandler

Advertisement