Created
May 26, 2020 08:00
-
-
Save edwin/320a1c2897c1bc7df82d80e93a331af5 to your computer and use it in GitHub Desktop.
This file contains 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() { | |
http.HandleFunc("/", handle) | |
http.ListenAndServe(":8080", nil) | |
} | |
func handle(w http.ResponseWriter, r *http.Request) { | |
if r.URL.Path != "/" { | |
http.NotFound(w, r) | |
return | |
} | |
w.Header().Set("Content-Type", "application/json") | |
fmt.Fprint(w, "{\"message\":\"Hello world!\"}") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment