xref: /unit/test/go/mirror/app.go (revision 1329:d4d7d2ca74b1)
1693Szelenkov@nginx.compackage main
2693Szelenkov@nginx.com
3693Szelenkov@nginx.comimport (
41120Szelenkov@nginx.com	"fmt"
51120Szelenkov@nginx.com	"io"
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	var buf [32768]byte
121120Szelenkov@nginx.com	len, _ := r.Body.Read(buf[:])
13693Szelenkov@nginx.com
141120Szelenkov@nginx.com	w.Header().Add("Content-Length", fmt.Sprintf("%v", len))
151120Szelenkov@nginx.com	io.WriteString(w, string(buf[:len]))
16693Szelenkov@nginx.com}
17693Szelenkov@nginx.com
18693Szelenkov@nginx.comfunc main() {
191120Szelenkov@nginx.com	http.HandleFunc("/", handler)
201120Szelenkov@nginx.com	unit.ListenAndServe(":7080", nil)
21693Szelenkov@nginx.com}
22