1
0
mirror of https://github.com/labstack/echo.git synced 2025-01-24 03:16:14 +02:00
Vishal Rana b6547dde66 recipe & website in the main repo
Signed-off-by: Vishal Rana <vr@labstack.com>
2016-10-20 11:30:53 -07:00

1.3 KiB

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

What is HTTP/2?

HTTP/2 (originally named HTTP/2.0) is the second major version of the HTTP network protocol used by the World Wide Web

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?

Standard engine only

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

Maintainers

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