change function name

NewServerConn->Server
NewClientConn->Client
merge_conn
fangdingjun 6 years ago
parent 503997660b
commit 68c8ece2c6

@ -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,

@ -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)
}

@ -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)
}

Loading…
Cancel
Save