O'Reilly logo

Go Standard Library Cookbook by Radomir Sohlich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

First, note that the HTTP/2 requires the secured connection. The server push is very simple to implement. Since Go 1.8, the HTTP package provides the Pusher interface, which could be used to Push the assets before they are required. If the client, usually browser, supports the HTTP/2 protocol and the handshake with the server is successful, the ResponseWriter in Handler or HandlerFunc could be cast to Pusher. The Pusher provides only the  Push method. The Push method consumes the target (which could be the absolute path or absolute URL) to resource and PushOptions, which can provide the additional options (by default the nil could be used).

In the preceding example, look at the output of the developer's tool in the browser. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required