xref: /unit/test/go/404/app.go (revision 1329:d4d7d2ca74b1)
1693Szelenkov@nginx.compackage main
2693Szelenkov@nginx.com
3693Szelenkov@nginx.comimport (
41120Szelenkov@nginx.com	"io"
51120Szelenkov@nginx.com	"io/ioutil"
61120Szelenkov@nginx.com	"net/http"
7*1329Smax.romanov@nginx.com	"unit.nginx.org/go"
8693Szelenkov@nginx.com)
9693Szelenkov@nginx.com
10693Szelenkov@nginx.comfunc handler(w http.ResponseWriter, r *http.Request) {
111120Szelenkov@nginx.com	b, e := ioutil.ReadFile("404.html")
12693Szelenkov@nginx.com
131120Szelenkov@nginx.com	if e == nil {
141120Szelenkov@nginx.com		w.WriteHeader(http.StatusNotFound)
151120Szelenkov@nginx.com		io.WriteString(w, string(b))
161120Szelenkov@nginx.com	}
17693Szelenkov@nginx.com}
18693Szelenkov@nginx.com
19693Szelenkov@nginx.comfunc main() {
201120Szelenkov@nginx.com	http.HandleFunc("/", handler)
211120Szelenkov@nginx.com	unit.ListenAndServe(":7080", nil)
22693Szelenkov@nginx.com}
23