Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Cmd = &cobra.Command{ Use: "server", Short: "Server with random data endpoints", Args: cobra.NoArgs, Run: func(c *cobra.Command, args []string) { portStr := strconv.Itoa(FlagPort) hostname, _ := os.Hostname() http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "[slu "+version.Version+"] Server with random data endpoints! %s %s \n", hostname, portStr) fmt.Printf("RemoteAddr=%s\n", r.RemoteAddr) }) http.HandleFunc("/v1/slu_random_password", func(w http.ResponseWriter, r *http.Request) { password, err := random_utils.RandomPassword() if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } fmt.Fprintf(w, "%s\n", password) }) fmt.Println("[slu " + version.Version + "] Server started on 0.0.0.0:" + portStr + ", see http://127.0.0.1:" + portStr) http.ListenAndServe(":"+portStr, nil) }, }
View Source
var FlagPort int
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.