Skip to content

Instantly share code, notes, and snippets.

@mstrYoda
Created February 5, 2023 15:04
Show Gist options
  • Save mstrYoda/92673435be7ff1b03594422968cd27f5 to your computer and use it in GitHub Desktop.
Save mstrYoda/92673435be7ff1b03594422968cd27f5 to your computer and use it in GitHub Desktop.
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