Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
503 views
in Technique[技术] by (71.8m points)

go - 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

question from:https://stackoverflow.com/questions/65895268/how-to-implement-h2c-http-2-plain-text-on-beego-framework

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...