Skip to content
This repository was archived by the owner on Aug 25, 2025. It is now read-only.

hertz-contrib/http3

 
 

Repository files navigation

Project Archival Notice

This project is no longer recommended for use and has been officially archived. The decision to archive is based on the following key considerations:

  • The project currently lacks clear end-user adoption and validated real-world implementation cases.
  • It does not meet the standard requirements for enterprise-level frameworks, which may lead to compatibility or maintenance issues in production environments.

We appreciate the interest and contributions this project has received. For enterprise-level use cases, we recommend exploring alternative solutions that align with industry best practices and have proven operational validity.

Hertz-HTTP3

This repo is the collection of Hertz HTTP3 implementations. Includes: Network layer & Protocol layer.

Network Layer

Currently, we provide 1 implementation of network layer which is based on: quic-go .

quic-go

Usage

package main

import (
	"github.com/cloudwego/hertz/pkg/app/server"
	"github.com/cloudwego/hertz/pkg/network/netpoll"
	"github.com/hertz-contrib/http3/network/quic-go"
	"github.com/hertz-contrib/http3/network/quic-go/testdata"
)

func main() {
	h := server.New(server.WithALPN(true), server.WithTLS(testdata.GetTLSConfig()), server.WithTransport(quic.NewTransporter), server.WithAltTransport(netpoll.NewTransporter), server.WithHostPorts("127.0.0.1:8080"))
	...

	h.Spin()
}

QUIC is forced to depend on TLS, so you need to provide a TLS configuration. For there is only Server side ready, we embed a testdata package from quic-go, which means the example server can directly communicate with the example client from quic-go.

Options

server.WithTransport() Use it to set the network layer implementation.

server.WithAltTransport() Use it to set the alternative network layer implementation. The AltTransporter will be used for parallel listening - both in TCP and QUIC.

server.WithALPN() Whether to enable ALPN.

server.WithTLS() Which TLS configuration to use.

server.WithHostPorts() Which host and port to listen on.

Protocol Layer

Currently, we provide 1 implementation of protocol layer which is also based on: quic-go .

quic-go

Usage

package main

import (
	"github.com/cloudwego/hertz/pkg/app/server"
	"github.com/cloudwego/hertz/pkg/network/netpoll"
	"github.com/cloudwego/hertz/pkg/protocol/suite"
	"github.com/hertz-contrib/http3/network/quic-go"
	"github.com/hertz-contrib/http3/network/quic-go/testdata"
	http3 "github.com/hertz-contrib/http3/server/quic-go"
	"github.com/hertz-contrib/http3/server/quic-go/factory"
)

func main() {
	h := server.New(server.WithALPN(true), server.WithTLS(testdata.GetTLSConfig()), server.WithTransport(quic.NewTransporter), server.WithAltTransport(netpoll.NewTransporter), server.WithHostPorts("127.0.0.1:8080"))
	h.AddProtocol(suite.HTTP3, factory.NewServerFactory(&http3.Option{}))
    ...
	
	h.Spin()
}

Example

For battery-included example, please refer to hertz-example.

Try using quic-go client to say hello to the server.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 5