mirror of
https://github.com/SourceFellows/gobuch.git
synced 2024-10-22 13:57:13 +00:00
25 lines
413 B
Go
25 lines
413 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
func handleCall(res http.ResponseWriter, req *http.Request) {
|
|
ctx := req.Context()
|
|
select {
|
|
case <-ctx.Done():
|
|
res.Write([]byte("end"))
|
|
fmt.Println("clsoing connection to client")
|
|
return
|
|
case <-time.After(20 * time.Second):
|
|
fmt.Fprintln(res, "Hello World")
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
http.HandleFunc("/", handleCall)
|
|
http.ListenAndServe(":8080", nil)
|
|
}
|