summaryrefslogblamecommitdiffhomepage
path: root/test/go/command_line_arguments/app.go
blob: 1101e1cf80d06d7a2e4f751d78c7fae58a9633a0 (plain) (tree)
1
2
3
4
5
6
7
8
9


            


                  
                           

                 


                                                      
                                              
 


                                                                      


             

                                         
 
package main

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

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)
}