publish ch1/...

This commit is contained in:
Alan Donovan
2015-10-16 09:12:59 -04:00
parent a99e98f589
commit 1d9c5ef8e2
13 changed files with 472 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
// Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan.
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
// See page 19.
//!+
// Server1 is a minimal "echo" server.
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
http.HandleFunc("/", handler) // each request calls handler
log.Fatal(http.ListenAndServe("localhost:8000", nil))
}
// handler echoes the Path component of the request URL r.
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "URL.Path = %q\n", r.URL.Path)
}
//!-