Created
February 5, 2023 15:04
-
-
Save mstrYoda/92673435be7ff1b03594422968cd27f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net" | |
"net/http" | |
) | |
type myHandler struct { | |
} | |
func (myHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { | |
w.Write([]byte("hello from myHandler")) | |
} | |
func main() { | |
srv := http.Server{ | |
Addr: ":8080", | |
Handler: myHandler{}, | |
ConnState: func(conn net.Conn, state http.ConnState) { | |
fmt.Println(conn.LocalAddr(), conn.RemoteAddr(), state.String()) | |
}, | |
} | |
srv.ListenAndServe() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment