Skip to content

Instantly share code, notes, and snippets.

@voluntas
Created August 22, 2023 00:55
Show Gist options
  • Save voluntas/c6d395ddfde71d3c94efd2adfdf5e3a3 to your computer and use it in GitHub Desktop.
Save voluntas/c6d395ddfde71d3c94efd2adfdf5e3a3 to your computer and use it in GitHub Desktop.
HTTP/2 over TCP
package main
import (
"net/http"
"github.com/labstack/echo/v4"
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
)
func main() {
e := echo.New()
h2s := &http2.Server{}
e.Server = &http.Server{
Addr: ":5555",
Handler: h2c.NewHandler(e, h2s),
}
e.GET(".ok", func(c echo.Context) error {
return c.String(200, "ok")
})
e.Server.ListenAndServe()
}
@voluntas
Copy link
Author

curl --http2-prior-knowledge -X GET http://127.0.0.1:5555/.ok

@voluntas
Copy link
Author

Image from Gyazo

@voluntas
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment