-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
39 lines (35 loc) · 845 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"fmt"
"strings"
"github.com/roceb/gUrl/parseArgs"
"github.com/roceb/gUrl/request"
"github.com/roceb/gUrl/response"
)
func main() {
// Think about adding Cobra
c := request.ParsedArgs{}
// spits out all arguements created after
args := parseArgs.ArgParser()
// assign Verb GET/PUT/ ...
parseArgs.AssignVerb(&c, strings.ToUpper(args[0]))
// assign url
parseArgs.AssignUrl(&c, args[1])
extraArgs := args[2:]
// TODO: create a data and header extractor
var headers []string
var data []string
for _, v := range extraArgs {
if strings.Contains(v, ":") {
headers = append(headers, v)
}
if strings.Contains(v, "=") {
data = append(data, v)
}
}
parseArgs.AssignData(&c, data)
req := response.PreRequest(&c)
request.AddHeader(req, headers)
resp := response.Call(&c, req)
fmt.Println(resp)
}