initial commit
Signed-off-by: Ava Hahn <a.hahn@f5.com>
This commit is contained in:
commit
4ee7c0cc18
13 changed files with 582 additions and 0 deletions
32
keepalive-svc.go
Executable file
32
keepalive-svc.go
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
type myHandler struct{
|
||||
nreq int
|
||||
}
|
||||
|
||||
func (h myHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Printf("accepted request number %d", h.nreq)
|
||||
fmt.Fprintf(w, "request number: %d", h.nreq)
|
||||
}
|
||||
|
||||
func main() {
|
||||
srv := &http.Server{
|
||||
Addr: ":8080",
|
||||
Handler: myHandler{nreq: 0},
|
||||
ReadTimeout: 5 * time.Second,
|
||||
WriteTimeout: 10 * time.Second,
|
||||
IdleTimeout: 300 * time.Second,
|
||||
ConnState: func(conn net.Conn, event http.ConnState) {
|
||||
fmt.Printf("addr: %s, changed state to: %s", conn.RemoteAddr(), event.String())
|
||||
},
|
||||
}
|
||||
|
||||
srv.ListenAndServe()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue