forked from RealImage/challenge2015
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
91 lines (75 loc) · 1.66 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package main
import (
"crypto/tls"
"encoding/json"
"fmt"
"net/http"
"os"
)
func main() {
args := os.Args
defer func() {
if err := recover(); err != nil {
fmt.Printf("\nPanic occurred: %+v", err)
return
}
}()
if len(args) < 3 || len(args) > 3 {
fmt.Println("invalid command line")
}
cmd := args[1]
var degree int
switch cmd {
default:
fmt.Println("\nInvalid command command line")
return
case "degrees":
fmt.Scanf("Degrees of Separation: %d", °ree)
}
movie := args[2]
person := args[3]
fetchInfo(movie, person)
}
func fetchInfo(movie, person string) {
}
type Movie struct {
URL string `json:"url"`
Name string `json:"name"`
Type string `json:"type"`
Cast []cast `json:"cast"`
}
// type cast struct {
// Name string `json:"name"`
// URL string `json:"url"`
// Role string `json:"role"`
// }
type Person struct {
URL string `json:"url"`
Name string `json:"name"`
Type string `json:"type"`
Movies []cast `json:"movies"`
}
func fetchMovie(movie, person string) {
baseURL := "http://data.moviebuff.com/"
movieURL := fmt.Sprint("%s%s", baseURL, movie)
req, err := http.NewRequest(http.MethodGet, movieURL, nil)
if err != nil {
//handle error
}
tlsConfig := tls.Config{
MinVersion: tls.VersionTLS13,
InsecureSkipVerify: true,
}
// Skipping verification as it is done manually using digest of the TLS certificate as this is step of setting up service
transport := http.Transport{
TLSClientConfig: &tlsConfig,
}
client := &http.Client{Transport: &transport}
resp, err := client.Do(req)
if err != nil {
}
err = json.NewDecoder(resp.Body).Decode(&userCreateResponse)
if err != nil {
return nil, err
}
}