Skip to content

Commit 0c50598

Browse files
committed
Code cleaned up
1 parent 065c974 commit 0c50598

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

controllers/functions.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ package controllers
33
import (
44
"fmt"
55
"io/ioutil"
6+
"log"
7+
"os"
8+
"os/exec"
69
)
710

811
func URLmethod() []string {
@@ -55,6 +58,14 @@ func GetHeader() []string {
5558
return args
5659
}
5760

61+
func SendRequest(args []string) {
62+
cmd := exec.Command("curl", args...)
63+
log.Println("curl ", args)
64+
cmd.Stdin = os.Stdin
65+
cmd.Stdout = os.Stdout
66+
cmd.Run()
67+
}
68+
5869
func loadFile(path string) string {
5970
b, err := ioutil.ReadFile(path)
6071
checkErr(err)

main.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ package main
33
import (
44
"fmt"
55
"http-request-creator/controllers"
6-
"log"
7-
"os"
8-
"os/exec"
96
)
107

118
func main() {
@@ -34,7 +31,7 @@ func main() {
3431
fmt.Scan(&option)
3532
if ynToBool(option) {
3633
fmt.Println("Sending request")
37-
sendRequest(args)
34+
controllers.SendRequest(args)
3835
} else {
3936
fmt.Println("Do you want to save request to file? [y/n]")
4037
fmt.Scan(&option)
@@ -54,11 +51,3 @@ func ynToBool(option string) bool {
5451
return false
5552
}
5653
}
57-
58-
func sendRequest(args []string) {
59-
cmd := exec.Command("curl", args...)
60-
log.Println("curl ", args)
61-
cmd.Stdin = os.Stdin
62-
cmd.Stdout = os.Stdout
63-
cmd.Run()
64-
}

0 commit comments

Comments
 (0)