github.com/gogf/gf@v1.16.9/.example/net/ghttp/server/nethttp_server.go (about)

     1  package main
     2  
     3  import (
     4  	"net/http"
     5  	"time"
     6  )
     7  
     8  func main() {
     9  	s := &http.Server{
    10  		Addr:         ":8199",
    11  		ReadTimeout:  2 * time.Second,
    12  		WriteTimeout: 2 * time.Second,
    13  	}
    14  	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
    15  		w.Write([]byte("hi"))
    16  		time.Sleep(3 * time.Second)
    17  	})
    18  	s.ListenAndServe()
    19  }