1
0
mirror of https://github.com/labstack/echo.git synced 2025-01-05 22:53:57 +02:00
echo/website/content/recipes/http2.md
Vishal Rana 73110004ef doc: updated, recipe: auto tls
Signed-off-by: Vishal Rana <vr@labstack.com>
2016-11-28 20:34:29 -08:00

1.3 KiB

+++ title = "HTTP/2 Example" description = "HTTP/2 example for Echo" [menu.main] name = "HTTP/2" parent = "recipes" weight = 3 +++

HTTP/2 (originally named HTTP/2.0) is the second major version of the HTTP network protocol used by the World Wide Web. HTTP/2 improves speed and provides better user experience.

Key Features

  • Binary, instead of textual.
  • Fully multiplexed, instead of ordered and blocking, can therefore use just one TCP connection.
  • Uses header compression to reduce overhead.
  • Allows servers to "push" responses proactively into client caches.

How to run an HTTP/2 and HTTPS server?

Generate a self-signed X.509 TLS certificate (HTTP/2 requires TLS to operate)

go run $GOROOT/src/crypto/tls/generate_cert.go --host localhost

This will generate cert.pem and key.pem files.

For demo purpose, we are using a self-signed certificate. Ideally you should obtain a certificate from CA.

Configure a server with engine.Config

server.go

{{< embed "http2/server.go" >}}

Endpoints

[Source Code]({{< source "http2" >}})

Maintainers