From 7cce9875c00783faa8619d06d572b19b770a1f26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B6=E8=BE=B0?= Date: Fri, 17 Jan 2020 15:52:37 +0800 Subject: [PATCH] update --- examples/hook.go | 4 ++-- examples/multi_port.go | 4 ++-- examples/simple.go | 4 ++-- examples/testserver.go | 4 ++-- examples/tls.go | 4 ++-- go.mod | 8 ++++++++ 6 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 go.mod diff --git a/examples/hook.go b/examples/hook.go index 1b4ceae..da3f12e 100644 --- a/examples/hook.go +++ b/examples/hook.go @@ -10,7 +10,7 @@ import ( "github.com/gorilla/mux" ) -func handler(w http.ResponseWriter, r *http.Request) { +func handlerHook(w http.ResponseWriter, r *http.Request) { w.Write([]byte("WORLD!")) } @@ -24,7 +24,7 @@ func postSigUsr1() { func main() { mux1 := mux.NewRouter() - mux1.HandleFunc("/hello", handler). + mux1.HandleFunc("/hello", handlerHook). Methods("GET") srv := endless.NewServer("localhost:4244", mux1) diff --git a/examples/multi_port.go b/examples/multi_port.go index fe98e04..43fbaf1 100644 --- a/examples/multi_port.go +++ b/examples/multi_port.go @@ -11,7 +11,7 @@ import ( "github.com/gorilla/mux" ) -func handler(w http.ResponseWriter, r *http.Request) { +func handlerPort(w http.ResponseWriter, r *http.Request) { w.Write([]byte("WORLD!")) } @@ -26,7 +26,7 @@ func handlerBar(w http.ResponseWriter, r *http.Request) { func main() { mux1 := mux.NewRouter() - mux1.HandleFunc("/hello", handler). + mux1.HandleFunc("/hello", handlerPort). Methods("GET") mux1.HandleFunc("/foo", handlerFoo). Methods("GET") diff --git a/examples/simple.go b/examples/simple.go index d62817e..36d5532 100644 --- a/examples/simple.go +++ b/examples/simple.go @@ -9,13 +9,13 @@ import ( "github.com/gorilla/mux" ) -func handler(w http.ResponseWriter, r *http.Request) { +func handlerSimple(w http.ResponseWriter, r *http.Request) { w.Write([]byte("WORLD!")) } func main() { mux1 := mux.NewRouter() - mux1.HandleFunc("/hello", handler). + mux1.HandleFunc("/hello", handlerSimple). Methods("GET") err := endless.ListenAndServe("localhost:4242", mux1) diff --git a/examples/testserver.go b/examples/testserver.go index 3f4ddc1..f7f83af 100644 --- a/examples/testserver.go +++ b/examples/testserver.go @@ -11,7 +11,7 @@ import ( "github.com/gorilla/mux" ) -func handler(w http.ResponseWriter, r *http.Request) { +func handlerTest(w http.ResponseWriter, r *http.Request) { time.Sleep(time.Duration(rand.Intn(2000)) * time.Millisecond) w.Write([]byte("bar\n")) } @@ -19,7 +19,7 @@ func handler(w http.ResponseWriter, r *http.Request) { func main() { // endless.DefaultHammerTime = 10*time.Second mux := mux.NewRouter() - mux.HandleFunc("/foo", handler). + mux.HandleFunc("/foo", handlerTest). Methods("GET") err := endless.ListenAndServe("localhost:4242", mux) diff --git a/examples/tls.go b/examples/tls.go index ddffa04..4462fba 100644 --- a/examples/tls.go +++ b/examples/tls.go @@ -9,14 +9,14 @@ import ( "github.com/gorilla/mux" ) -func handler(w http.ResponseWriter, r *http.Request) { +func handlerTls(w http.ResponseWriter, r *http.Request) { w.Write([]byte("WORLD!")) } func main() { mux1 := mux.NewRouter() mux1.Schemes("https") - mux1.HandleFunc("/hello", handler). + mux1.HandleFunc("/hello", handlerTls). Methods("GET") err := endless.ListenAndServeTLS("localhost:4242", "cert.pem", "key.pem", mux1) diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..de3d254 --- /dev/null +++ b/go.mod @@ -0,0 +1,8 @@ +module endless + +go 1.13 + +require ( + github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6 + github.com/gorilla/mux v1.7.3 +)