Created
February 3, 2021 01:46
-
-
Save shazadbrohi/ebff793d2c8ecf136fc2066e44384793 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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