xref: /unit/test/go/404/app.go (revision 1120)
1693Szelenkov@nginx.compackage main
2693Szelenkov@nginx.com
3693Szelenkov@nginx.comimport (
4*1120Szelenkov@nginx.com	"io"
5*1120Szelenkov@nginx.com	"io/ioutil"
6*1120Szelenkov@nginx.com	"net/http"
7*1120Szelenkov@nginx.com	"nginx/unit"
8693Szelenkov@nginx.com)
9693Szelenkov@nginx.com
10693Szelenkov@nginx.comfunc handler(w http.ResponseWriter, r *http.Request) {
11*1120Szelenkov@nginx.com	b, e := ioutil.ReadFile("404.html")
12693Szelenkov@nginx.com
13*1120Szelenkov@nginx.com	if e == nil {
14*1120Szelenkov@nginx.com		w.WriteHeader(http.StatusNotFound)
15*1120Szelenkov@nginx.com		io.WriteString(w, string(b))
16*1120Szelenkov@nginx.com	}
17693Szelenkov@nginx.com}
18693Szelenkov@nginx.com
19693Szelenkov@nginx.comfunc main() {
20*1120Szelenkov@nginx.com	http.HandleFunc("/", handler)
21*1120Szelenkov@nginx.com	unit.ListenAndServe(":7080", nil)
22693Szelenkov@nginx.com}
23