summaryrefslogtreecommitdiffhomepage
path: root/test/go/command_line_arguments/app.go
blob: 228e07c00d1e32dd39d00046a4fd8d41155b8820 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package main

import (
    "io"
    "os"
    "fmt"
    "strings"
    "net/http"
    "nginx/unit"
)

func handler(w http.ResponseWriter, r *http.Request) {
    args := strings.Join(os.Args[1:], ",")

    w.Header().Add("X-Arg-0", fmt.Sprintf("%v", os.Args[0]))
    w.Header().Add("Content-Length", fmt.Sprintf("%v", len(args)))
    io.WriteString(w, args)
}

func main() {
    http.HandleFunc("/", handler)
    unit.ListenAndServe(":7080", nil)
}