Golang net/http.ServeFile() function example

package net/http

Golang net/http.ServeFile() function usage example

 http.HandleFunc("/filestobeserved/", func(w http.ResponseWriter, r *http.Request) {
 http.ServeFile(w, r, "filename.txt")
 })

See also : https://www.socketloop.com/tutorials/golang-how-to-stream-file-to-client-browser-or-write-to-http-responsewriter

References :

http://golang.org/pkg/net/http/#ServeFile

https://www.socketloop.com/tutorials/golang-how-to-stream-file-to-client-browser-or-write-to-http-responsewriter

Advertisement