Skip to content

Instantly share code, notes, and snippets.

@kawakami-o3
Created February 27, 2018 11:30
Show Gist options
  • Save kawakami-o3/e4e3c6d124a2986134e26da24ad3a6f5 to your computer and use it in GitHub Desktop.
Save kawakami-o3/e4e3c6d124a2986134e26da24ad3a6f5 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"net"
"net/http"
)
type MyMux struct {
}
func (p *MyMux) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/" {
sayhelloName(w, r)
return
}
http.NotFound(w, r)
return
}
func sayhelloName(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello myroute!")
}
func main() {
/*
mux := &MyMux{}
http.ListenAndServe(":9080", mux)
*/
addr := ":9080"
ln, err := net .Listen("tcp", addr)
if err != nil {
fmt.Println(err)
return
}
defer ln.Close()
//err := srv.Serve(tcpKeepAliveListener{ln.(*net.TCPListener)})
fmt.Println(ln)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment