Documentation
¶
Overview ¶
Package h2c implements the h2c part of HTTP/2.
The h2c protocol is the non-TLS secured version of HTTP/2 which is not available from net/http.
Code is a copy of Traefik's h2c server, but adapted for standalone usage as an http.Handler.
Traefik can be found here: github.com/containous/traefik
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HandlerH2C ¶
HandlerH2C implements http.Handler and enables h2c. Users who want h2c just need to provide a http.Handler to wrap, and an http2.Server.
Example:
router := http.NewServeMux()
router.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Hello World")
})
h2cWrapper := &h2c.HandlerH2C{
Handler: router,
H2Server: &http2.Server{},
}
srv := http.Server{
Addr: ":8080",
Handler: h2cWrapper,
}
srv.ListenAndServe()
func (*HandlerH2C) ServeHTTP ¶
func (h *HandlerH2C) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP will serve with an HTTP/2 connection if possible using the `H2Server`. The request will be handled by the wrapped `Handler` in any case.
Click to show internal directories.
Click to hide internal directories.