Skip to content

Instantly share code, notes, and snippets.

@samirkape
Last active February 22, 2021 13:11
Show Gist options
  • Save samirkape/afe02fe7e334e14fccb2b9226d53525f to your computer and use it in GitHub Desktop.
Save samirkape/afe02fe7e334e14fccb2b9226d53525f to your computer and use it in GitHub Desktop.
// a minimal http server
package main
import (
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, "hello\n")
}
func main() {
http.HandleFunc("/hello", handler)
http.ListenAndServe("localhost:8090", nil)
}
/*
$ go run http-servers.go &
$ curl localhost:8090/hello
hello
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment