diff options
| author | Juan Roig <jaroig@outlook.com> | 2023-11-13 02:08:03 -0500 |
|---|---|---|
| committer | Juan Roig <jaroig@outlook.com> | 2023-11-13 02:08:03 -0500 |
| commit | e46ca43d4cd6e44972123856bbe047eb0517768e (patch) | |
| tree | a3542a6c165525fd1665aebf12a8ef73c0f6ae16 /canvas.go | |
| parent | 78fd5e4e1f084b1f031c80c964f795e225f0d25a (diff) | |
Move aplus requests to new launch_aplus function
Diffstat (limited to 'canvas.go')
| -rw-r--r-- | canvas.go | 17 |
1 files changed, 17 insertions, 0 deletions
| @@ -5,18 +5,35 @@ import ( | |||
| 5 | "fmt" | 5 | "fmt" |
| 6 | "io" | 6 | "io" |
| 7 | "net/http" | 7 | "net/http" |
| 8 | "net/http/cookiejar" | ||
| 8 | "os" | 9 | "os" |
| 10 | |||
| 11 | "golang.org/x/net/publicsuffix" | ||
| 9 | ) | 12 | ) |
| 10 | 13 | ||
| 11 | func initialize() { | 14 | func initialize() { |
| 12 | base_link = "https://floridapolytechnic.instructure.com/api/v1" | 15 | base_link = "https://floridapolytechnic.instructure.com/api/v1" |
| 13 | token = os.Getenv("CANVAS_API_KEY") | 16 | token = os.Getenv("CANVAS_API_KEY") |
| 17 | |||
| 18 | jar, _ := cookiejar.New(&cookiejar.Options{ | ||
| 19 | PublicSuffixList: publicsuffix.List, | ||
| 20 | }) | ||
| 21 | |||
| 22 | client = http.Client{ | ||
| 23 | CheckRedirect: func(req *http.Request, via []*http.Request) error { | ||
| 24 | fmt.Println("Redirected to:", req.URL) | ||
| 25 | fmt.Println(req.Cookies()) | ||
| 26 | return nil | ||
| 27 | }, | ||
| 28 | Jar: jar, | ||
| 29 | } | ||
| 14 | } | 30 | } |
| 15 | 31 | ||
| 16 | func get_courses(token string, link string, client http.Client) []CanvasCourse { | 32 | func get_courses(token string, link string, client http.Client) []CanvasCourse { |
| 17 | resp, err := client.Get(link) | 33 | resp, err := client.Get(link) |
| 18 | if err != nil { | 34 | if err != nil { |
| 19 | fmt.Println("Error performing GET request to get courses.") | 35 | fmt.Println("Error performing GET request to get courses.") |
| 36 | return nil | ||
| 20 | } | 37 | } |
| 21 | defer resp.Body.Close() | 38 | defer resp.Body.Close() |
| 22 | body, _ := io.ReadAll(resp.Body) | 39 | body, _ := io.ReadAll(resp.Body) |
