diff --git a/conn.go b/conn.go index cb2dcb9..fdfb935 100644 --- a/conn.go +++ b/conn.go @@ -34,8 +34,8 @@ type ClientConn struct { err error } -// NewClientConn create http2 client -func NewClientConn(c net.Conn) (*ClientConn, error) { +// Client create http2 client +func Client(c net.Conn) (*ClientConn, error) { conn := &ClientConn{ conn: c, streams: make(map[int]*ClientStream), lock: new(sync.Mutex), @@ -272,15 +272,15 @@ type ServerConn struct { // } // srv.ServeTLS(l, "server.crt", "server.key") func HTTP2Handler(srv *http.Server, conn *tls.Conn, handler http.Handler) { - h2conn, err := NewServerConn(conn, handler) + h2conn, err := Server(conn, handler) if err != nil { panic(err.Error()) } h2conn.Run() } -// NewServerConn create new server connection -func NewServerConn(c net.Conn, handler http.Handler) (*ServerConn, error) { +// Server create new server connection +func Server(c net.Conn, handler http.Handler) (*ServerConn, error) { conn := &ServerConn{ conn: c, Handler: handler, diff --git a/doc.go b/doc.go index 5d1ecba..a35e952 100644 --- a/doc.go +++ b/doc.go @@ -35,7 +35,7 @@ server example if err != nil { break } - h2conn, err := NewServerConn(c, nil) + h2conn, err := Server(c, nil) if err != nil { t.Fatal(err) } @@ -59,7 +59,7 @@ client example t.Fatal("no http2 on server") } - h2conn, err := NewClientConn(conn) + h2conn, err := Client(conn) if err != nil { t.Fatal(err) } diff --git a/http2_test.go b/http2_test.go index 5233a99..006e2f1 100644 --- a/http2_test.go +++ b/http2_test.go @@ -29,7 +29,7 @@ func TestHttp2Client(t *testing.T) { if cstate.NegotiatedProtocol != "h2" { t.Fatal("no http2 on server") } - h2conn, err := NewClientConn(conn) + h2conn, err := Client(conn) if err != nil { t.Fatal(err) } @@ -102,7 +102,7 @@ func TestHttp2Server(t *testing.T) { if err != nil { break } - h2conn, err := NewServerConn(c, nil) + h2conn, err := Server(c, nil) if err != nil { t.Fatal(err) }