golang serving up files example


This is an example to serve file over http2.




func index_main(w http.ResponseWriter, r *http.Request) {
    http.ServeFile(w, r, "your_file_name.pdf")
}

func main() {

    var srv http.Server
    srv.Addr = ":8002"

    //Enable http2
    http2.ConfigureServer(&srv, nil)

    http.HandleFunc("/", index_main)

    err := srv.ListenAndServeTLS("certs/localhost.cert", "certs/localhost.key")

    if err != nil {
        fmt.Println(err)
    }

}

Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm