Skip to content

Instantly share code, notes, and snippets.

@shazadbrohi
Created February 3, 2021 01:46
Show Gist options
  • Save shazadbrohi/ebff793d2c8ecf136fc2066e44384793 to your computer and use it in GitHub Desktop.
Save shazadbrohi/ebff793d2c8ecf136fc2066e44384793 to your computer and use it in GitHub Desktop.
package main
import ("fmt"
"net/http"
)
func main(){
rootHttpHandler := func(writer http.ResponseWriter, request *http.Request) {
fmt.Fprintf(writer, "Request Method: %s\n", request.Method)
fmt.Fprintf(writer, "Request Method: %q\n", request.URL)
fmt.Fprintf(writer, "Request Method: %s\n", request.Host)
fmt.Fprintf(writer, "Request Method: %s\n", request.Proto)
}
demoHttpHandler := func(writer http.ResponseWriter, request *http.Request) {
fmt.Fprintf(writer, "Served from the demo endpoint: %s\n", request.URL.Path)
}
http.HandleFunc("/", rootHttpHandler)
http.HandleFunc("/demo", demoHttpHandler)
http.ListenAndServe(":9000", nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment