1package main 2 3import (
| 1package main 2 3import (
|
4 "io" 5 "io/ioutil" 6 "net/http" 7 "nginx/unit"
| 4 "io" 5 "io/ioutil" 6 "net/http" 7 "nginx/unit"
|
8) 9 10func handler(w http.ResponseWriter, r *http.Request) {
| 8) 9 10func handler(w http.ResponseWriter, r *http.Request) {
|
11 b, e := ioutil.ReadFile("404.html")
| 11 b, e := ioutil.ReadFile("404.html")
|
12
| 12
|
13 if e == nil { 14 w.WriteHeader(http.StatusNotFound) 15 io.WriteString(w, string(b)) 16 }
| 13 if e == nil { 14 w.WriteHeader(http.StatusNotFound) 15 io.WriteString(w, string(b)) 16 }
|
17} 18 19func main() {
| 17} 18 19func main() {
|
20 http.HandleFunc("/", handler) 21 unit.ListenAndServe(":7080", nil)
| 20 http.HandleFunc("/", handler) 21 unit.ListenAndServe(":7080", nil)
|
22}
| 22}
|