Skip to content

Instantly share code, notes, and snippets.

@edwin
Created May 26, 2020 08:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edwin/320a1c2897c1bc7df82d80e93a331af5 to your computer and use it in GitHub Desktop.
Save edwin/320a1c2897c1bc7df82d80e93a331af5 to your computer and use it in GitHub Desktop.
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