func (c counter) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
	key := []byte(req.URL.String())

	// Decode handles key not found for us.
	value, _ := c.hits.Get(key)
	count := decode(value) + 1

	if err := c.hits.Put(key, encode(count)); err != nil {
		http.Error(rw, err.Error(), 500)
		return
	}

	if verbose {
		log.Printf("server: %s: %d", req.URL.String(), count)
	}

	// Reply with the new count .
	rw.Header().Set("Content-Type", "application/octet-stream")
	fmt.Fprintf(rw, "%d\n", count)
}
// Our handler communicates the new count from a successful database
// transaction.
Our handler communicates the new count from a successful database
transaction.
// Our handler communicates the new count from a successful database // transaction .
func (c counter) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
	key := []byte(req.URL.String())
	value, _ := c.hits.Get(key)
	count := decode(value) + 1
	if err := c.hits.Put(key, encode(count)); err != nil {
		http.Error(rw, err.Error(), 500)
		return
	}
	if verbose {
		log.Printf("server: %s: %d", req.URL.String(), count)
	}
	rw.Header().Set("Content-Type", "application/octet-stream")
	fmt.Fprintf(rw, "%d\n", count)
}
func ( c counter ) ServeHTTP ( rw http . ResponseWriter , req * http . Request ) { key := [ ] byte ( req . URL . String ( ) ) value , _ := c . hits . Get ( key ) count := decode ( value ) + 1 if err := c . hits . Put ( key , encode ( count ) ) ; err != nil { http . Error ( rw , err . Error ( ) , 500 ) return } if verbose { log . Printf ( " " , req . URL . String ( ) , count ) } rw . Header ( ) . Set ( " " , " " ) fmt . Fprintf ( rw , " \n " , count ) }
Our handler communicates the new count from a successful database
transaction.
Our handler communicates the new count from a successful database transaction .
// Decode handles key not found for us. // Reply with the new count .