Skip to content
/ http2 Public
forked from dgrr/http2

HTTP/2 implementation for fasthttp

License

Notifications You must be signed in to change notification settings

ip-rw/http2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTTP2

http2 is a implementation of HTTP/2 protocol for fasthttp.

Download

go get github.com/ip-rw/http2@v0.0.7

Help

If you need any help setting up, contributing or understanding this repo, you can contact me on gofiber's Discord.

How to use the server?

The server can only be used if your server supports TLS. Then, you can call ConfigureServer.

import (
	"github.com/valyala/fasthttp"
	"github.com/ip-rw/http2/fasthttp2"
)

func main() {
    s := &fasthttp.Server{
        Handler: yourHandler,
        Name:    "HTTP2 test",
    }

    fasthttp2.ConfigureServer(s)
    
    s.ListenAndServeTLS(...)
}

How to use the client?

The HTTP/2 client only works with the HostClient.

package main

import (
        "fmt"
        "log"

        "github.com/ip-rw/http2/fasthttp2"
        "github.com/valyala/fasthttp"
)

func main() {
        hc := &fasthttp.HostClient{
                Addr:  "api.binance.com:443",
                IsTLS: true,
        }

        if err := fasthttp2.ConfigureClient(hc); err != nil {
                log.Printf("%s doesn't support http/2\n", hc.Addr)
        }

        statusCode, body, err := hc.Get(nil, "https://api.binance.com/api/v3/time")
        if err != nil {
                log.Fatalln(err)
        }

        fmt.Printf("%d: %s\n", statusCode, body)
}

About

HTTP/2 implementation for fasthttp

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%