Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Cmd = &cobra.Command{ Use: "long-response", Short: "Server with long response time", Aliases: []string{"long", "lr", "lore"}, Args: cobra.NoArgs, Run: func(c *cobra.Command, args []string) { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { hostname, _ := os.Hostname() sleepTime, err := strconv.Atoi(strings.ReplaceAll(r.URL.Path, "/", "")) if err != nil { fmt.Println(err) fmt.Println("set sleep time to 0s (default)") } time.Sleep(time.Duration(sleepTime) * time.Second) fmt.Fprintf(w, "[slu-debug-server] Response after %ds! %s \n", sleepTime, hostname) }) fmt.Println("Server started on 0.0.0.0:8000, see http://127.0.0.1:8000") http.ListenAndServe(":8000", nil) }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.