Socket
Socket
Sign inDemoInstall

github.com/quic-go/webtransport-go

Package Overview
Dependencies
19
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github.com/quic-go/webtransport-go


Version published

Readme

Source

webtransport-go

PkgGoDev Code Coverage

webtransport-go is an implementation of the WebTransport protocol, based on quic-go. It currently implements draft-02 of the specification.

Running a Server

// create a new webtransport.Server, listening on (UDP) port 443
s := webtransport.Server{
    H3: http3.Server{Addr: ":443"},
}

// Create a new HTTP endpoint /webtransport.
http.HandleFunc("/webtransport", func(w http.ResponseWriter, r *http.Request) {
    conn, err := s.Upgrade(w, r)
    if err != nil {
        log.Printf("upgrading failed: %s", err)
        w.WriteHeader(500)
        return
    }
    // Handle the connection. Here goes the application logic. 
})

s.ListenAndServeTLS(certFile, keyFile)

Now that the server is running, Chrome can be used to establish a new WebTransport session as described in this tutorial.

Running a Client

var d webtransport.Dialer
rsp, conn, err := d.Dial(ctx, "https://example.com/webtransport", nil)
// err is only nil if rsp.StatusCode is a 2xx
// Handle the connection. Here goes the application logic.

FAQs

Last updated on 24 Sep 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc