make h2quic.Server.Serve panic

ref #124
This commit is contained in:
Lucas Clemente
2016-05-30 17:18:10 +02:00
parent 25c34723a3
commit 33edcc5e88
2 changed files with 12 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ import (
"crypto/tls"
"errors"
"io/ioutil"
"net"
"net/http"
"time"
@@ -61,6 +62,11 @@ func (s *Server) ListenAndServeTLS(certFile, keyFile string) error {
return server.ListenAndServe()
}
// Serve should not be called, since it only works properly for TCP listeners.
func (Server) Serve(net.Listener) error {
panic("h2quic.Server.Serve should not be called, see https://godoc.org/github.com/lucas-clemente/quic-go/h2quic")
}
func (s *Server) handleStreamCb(session *quic.Session, stream utils.Stream) {
s.handleStream(session, stream)
}

View File

@@ -151,4 +151,10 @@ var _ = Describe("H2 server", func() {
s.handleStream(session, headerStream)
Eventually(func() bool { return handlerCalled }).Should(BeTrue())
})
It("should panic when Serve() is called", func() {
Expect(func() {
Server{}.Serve(nil)
}).To(Panic())
})
})