xref: /unit/test/go/command_line_arguments/app.go (revision 1329:d4d7d2ca74b1)
1package main
2
3import (
4	"fmt"
5	"io"
6	"net/http"
7	"unit.nginx.org/go"
8	"os"
9	"strings"
10)
11
12func handler(w http.ResponseWriter, r *http.Request) {
13	args := strings.Join(os.Args[1:], ",")
14
15	w.Header().Add("X-Arg-0", fmt.Sprintf("%v", os.Args[0]))
16	w.Header().Add("Content-Length", fmt.Sprintf("%v", len(args)))
17	io.WriteString(w, args)
18}
19
20func main() {
21	http.HandleFunc("/", handler)
22	unit.ListenAndServe(":7080", nil)
23}
24