Skip to content

Instantly share code, notes, and snippets.

@rodesousa
Created February 11, 2018 22:06
Show Gist options
  • Select an option

  • Save rodesousa/d1570d03d4adf791fcd16a3bb23daafe to your computer and use it in GitHub Desktop.

Select an option

Save rodesousa/d1570d03d4adf791fcd16a3bb23daafe to your computer and use it in GitHub Desktop.
simply_handler #golang
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
body, _ := ioutil.ReadAll(r.Body)
fmt.Println(string(body))
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment