Update to gobook@5e58e0a92b96bee61856a8ce6e75ed849bd504af

This commit is contained in:
Alan Donovan
2015-11-08 17:37:46 -05:00
parent 8eb326f5e8
commit 8908af67d0
7 changed files with 13 additions and 30 deletions
+1 -16
View File
@@ -2,24 +2,18 @@
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
// See page 21.
//!+
// Server3 is a minimal "echo" and counter server.
// Server3 is an "echo" server that displays request parameters.
package main
import (
"fmt"
"log"
"net/http"
"sync"
)
var mu sync.Mutex
var count int
func main() {
http.HandleFunc("/", handler)
http.HandleFunc("/count", counter)
log.Fatal(http.ListenAndServe("localhost:8000", nil))
}
@@ -41,12 +35,3 @@ func handler(w http.ResponseWriter, r *http.Request) {
}
//!-handler
// counter echoes the number of calls so far.
func counter(w http.ResponseWriter, r *http.Request) {
mu.Lock()
fmt.Fprintf(w, "Count %d", count)
mu.Unlock()
}
//!-