Skip to content

Commit df575f2

Browse files
committed
Cleaned up code, fixed bugs
1 parent baa569f commit df575f2

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

main.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
)
88

99
func main() {
10+
var args []string
1011
var url string
1112
var method string
1213
var option string
@@ -16,8 +17,11 @@ func main() {
1617
fmt.Println("Starting HTTP request creator")
1718
fmt.Println("HTTP request URL: ")
1819
fmt.Scan(&url)
20+
args = append(args, url)
1921
fmt.Println("What HTTP method do you want to use: ")
2022
fmt.Scan(&method)
23+
args = append(args, "-X")
24+
args = append(args, url)
2125

2226
//* HTTP REQUEST BODY
2327
fmt.Println("Do you want to add body to the request? [y/n]")
@@ -32,18 +36,23 @@ func main() {
3236
if option == "2" {
3337
fmt.Println("Path to json file: ")
3438
}
39+
args = append(args, "--body")
40+
args = append(args, body)
3541
}
3642

3743
//* HTTP REQUEST HEADER
3844
fmt.Println("Header: ")
3945
fmt.Scan(&header)
46+
// args = append(args, "--header")
47+
// args = append(args, header)
4048

4149
//* HTTP REQUEST SENDING
4250
fmt.Println("Do you want to send request? [y/n]")
4351
fmt.Scan(&option)
4452
if ynToBool(option) {
4553
fmt.Println("Sending request")
46-
cmd := exec.Command("curl", "-X", method, url)
54+
//! HEADER nil, body nil
55+
cmd := exec.Command("curl", args...)
4756
cmd.Stdin = os.Stdin
4857
cmd.Stdout = os.Stdout
4958
cmd.Run()

0 commit comments

Comments
 (0)