|
|
@ -34,8 +34,8 @@ type ClientConn struct {
|
|
|
|
err error
|
|
|
|
err error
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// NewClientConn create http2 client
|
|
|
|
// Client create http2 client
|
|
|
|
func NewClientConn(c net.Conn) (*ClientConn, error) {
|
|
|
|
func Client(c net.Conn) (*ClientConn, error) {
|
|
|
|
conn := &ClientConn{
|
|
|
|
conn := &ClientConn{
|
|
|
|
conn: c, streams: make(map[int]*ClientStream),
|
|
|
|
conn: c, streams: make(map[int]*ClientStream),
|
|
|
|
lock: new(sync.Mutex),
|
|
|
|
lock: new(sync.Mutex),
|
|
|
@ -272,15 +272,15 @@ type ServerConn struct {
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// srv.ServeTLS(l, "server.crt", "server.key")
|
|
|
|
// srv.ServeTLS(l, "server.crt", "server.key")
|
|
|
|
func HTTP2Handler(srv *http.Server, conn *tls.Conn, handler http.Handler) {
|
|
|
|
func HTTP2Handler(srv *http.Server, conn *tls.Conn, handler http.Handler) {
|
|
|
|
h2conn, err := NewServerConn(conn, handler)
|
|
|
|
h2conn, err := Server(conn, handler)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
panic(err.Error())
|
|
|
|
panic(err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
h2conn.Run()
|
|
|
|
h2conn.Run()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// NewServerConn create new server connection
|
|
|
|
// Server create new server connection
|
|
|
|
func NewServerConn(c net.Conn, handler http.Handler) (*ServerConn, error) {
|
|
|
|
func Server(c net.Conn, handler http.Handler) (*ServerConn, error) {
|
|
|
|
conn := &ServerConn{
|
|
|
|
conn := &ServerConn{
|
|
|
|
conn: c,
|
|
|
|
conn: c,
|
|
|
|
Handler: handler,
|
|
|
|
Handler: handler,
|
|
|
|