Golang net/http.ProxyFromEnvironment() function example
package net/http
Golang net/http.ProxyFromEnvironment() function usage example
package main
import (
"net/http"
)
func Hello(w http.ResponseWriter, req *http.Request) {
html := "Hello World!\n"
url, _ := http.ProxyFromEnvironment(req)
if url != nil {
html = html + "scheme " + url.Scheme + "\n"
html = html + "host " + url.Scheme + "\n"
} else {
html = html + "proxy returns empty url\n"
}
w.Write([]byte(html))
}
func main() {
http.HandleFunc("/", Hello)
http.ListenAndServe(":8080", nil)
}
Reference :
Advertisement
Something interesting
Tutorials
+10.6k Golang : Allow Cross-Origin Resource Sharing request
+8.2k Android Studio : Rating bar example
+6.1k Golang : Measure execution time for a function
+11.6k Golang : Surveillance with web camera and OpenCV
+33.7k Golang : All update packages with go get command
+12k Golang : Find and draw contours with OpenCV example
+8.2k Golang : Get final or effective URL with Request.URL example
+6.1k Golang : Dealing with backquote
+19.2k Golang : Execute shell command
+29.9k Golang : Get and Set User-Agent examples
+6.1k Golang : Debug with Godebug