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
+13.7k Golang : Image to ASCII art example
+15.7k Golang : Intercept Ctrl-C interrupt or kill signal and determine the signal type
+9.1k Golang : Get curl -I or head data from URL example
+9.1k Golang : Gonum standard normal random numbers example
+19.5k Golang : Example for DSA(Digital Signature Algorithm) package functions
+7.1k Restart Apache or Nginx web server without password prompt
+19.6k Golang : Set or Add HTTP Request Headers
+11.5k Use systeminfo to find out installed Windows Hotfix(s) or updates
+7.1k Golang : Validate credit card example
+8.1k Golang : How To Use Panic and Recover
+12.8k Golang : Convert int(year) to time.Time type
+12.9k Golang : Convert IPv4 address to packed 32-bit binary format