Created
October 1, 2017 03:26
-
-
Save ariefrahmansyah/803657a0049fc0aef891051ba13da20c to your computer and use it in GitHub Desktop.
Simple HTTP Server in Go Programming Language
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 ( | |
"net/http" | |
"os" | |
) | |
func main() { | |
port := os.Getenv("PORT") | |
if port == "" { | |
port = "8080" | |
} | |
http.HandleFunc("/ping", ping) | |
http.ListenAndServe(":"+port, nil) | |
} | |
func ping(w http.ResponseWriter, r *http.Request) { | |
w.Write([]byte("pong\n")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment