https://github.com/fasthttp/http2
HTTP/2 implementation for fasthttp (Under construction...)
https://github.com/fasthttp/http2
Last synced: 5 months ago
JSON representation
HTTP/2 implementation for fasthttp (Under construction...)
- Host: GitHub
- URL: https://github.com/fasthttp/http2
- Owner: fasthttp
- License: apache-2.0
- Created: 2018-08-25T07:09:43.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2022-01-13T20:51:08.000Z (over 4 years ago)
- Last Synced: 2024-06-18T21:46:46.198Z (about 2 years ago)
- Language: Go
- Homepage:
- Size: 10.2 MB
- Stars: 119
- Watchers: 8
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# HTTP2
http2 is an implementation of HTTP/2 protocol for [fasthttp](https://github.com/valyala/fasthttp).
# Download
```bash
go get github.com/dgrr/http2@v0.2.12
```
# Help
If you need any help to set up, contributing or understanding this repo, you can contact me on [gofiber's Discord](https://gofiber.io/discord).
# How to use the server?
The server can only be used if your server supports TLS.
Then, you can call [ConfigureServer](https://pkg.go.dev/github.com/dgrr/http2#ConfigureServer).
```go
package main
import (
"github.com/valyala/fasthttp"
"github.com/dgrr/http2"
)
func main() {
s := &fasthttp.Server{
Handler: yourHandler,
Name: "HTTP2 test",
}
http2.ConfigureServer(s, http2.ServerConfig{})
s.ListenAndServeTLS(...)
}
```
# How to use the client?
The HTTP/2 client only works with the HostClient.
```go
package main
import (
"fmt"
"log"
"github.com/dgrr/http2"
"github.com/valyala/fasthttp"
)
func main() {
hc := &fasthttp.HostClient{
Addr: "api.binance.com:443",
}
if err := http2.ConfigureClient(hc, http2.ClientOpts{}); 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)
}
```