Fitrah Elly Firdaus
Fitrah Elly Firdaus

Reputation: 41

How to implement H2C (HTTP/2 Plain Text) on Beego Framework

Is there anybody that success implement h2c(HTTP/2 Plain text) Protocol in beego as a server?

I have tried to use http/2 from golang.org/x/net/http2 package using this approach https://beego.me/docs/mvc/controller/router.md#handler-register

I have implemented like this

h2server := &http2.Server{}

    handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        _, _ = fmt.Fprintf(w, "Hello, %v, http: %v", r.URL.Path, r.TLS == nil)
    })

    server := &http.Server{
        Addr:    "0.0.0.0:" + strconv.Itoa(beego.BConfig.Listen.HTTPPort),
        Handler: h2c.NewHandler(handler, h2server),
    }

But all of my beego.router must move into the handler.

Is there any other better approach with that?

Thanks

FEF

Upvotes: 1

Views: 325

Answers (0)

Related Questions