Skip to content

Instantly share code, notes, and snippets.

@fwojciec
Created July 23, 2018 08:06
Show Gist options
  • Save fwojciec/a1d0c9f71e6696677e00be9e3b8bdabf to your computer and use it in GitHub Desktop.
Save fwojciec/a1d0c9f71e6696677e00be9e3b8bdabf to your computer and use it in GitHub Desktop.
My solution to "Exercise Bye, web" from Section 02 of Francesc Campoy's Go Web Workshop
// https://github.com/campoy/go-web-workshop/blob/master/section02/README.md
package main
import (
"fmt"
"log"
"net/http"
)
func helloHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello, web")
}
func byeHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Bye, web")
}
func main() {
http.HandleFunc("/hello", helloHandler)
http.HandleFunc("/bye", byeHandler)
err := http.ListenAndServe(":8080", nil)
if err != nil {
log.Fatal(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment