Skip to content

Commit cf2f437

Browse files
committed
Initial commit
0 parents  commit cf2f437

File tree

7 files changed

+91
-0
lines changed

7 files changed

+91
-0
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
8+
# Test binary, build with `go test -c`
9+
*.test
10+
11+
# Output of the go coverage tool, specifically when used with LiteIDE
12+
*.out

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# pubg_stat_tracker

main.go

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package main
2+
3+
import (
4+
"net/http"
5+
)
6+
7+
func main() {
8+
9+
//client := &http.Client{}
10+
req, _ := http.NewRequest("GET", "endpoint-url", nil)
11+
req.Header.Set("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJkNTFmY2Q5MC00YjBiLTAxMzYtNDRjNy0wZTc3YzRhYzg5MmEiLCJpc3MiOiJnYW1lbG9ja2VyIiwiaWF0IjoxNTI4MjE2MjkzLCJwdWIiOiJibHVlaG9sZSIsInRpdGxlIjoicHViZyIsImFwcCI6InB1Ymdfc3RhdF90cmFja2VyLTRhNzk1M2NkLTIzZDktNDJmNy05ZWNjLWJjNTY1YzQwZDcxNyJ9.i5b0XrU11RA8oq4bXRdr4NekwickWaqMt1GHJc71m40")
12+
req.Header.Set("Accept", "application/vnd.api+json")
13+
//res, _ := client.Do(req)
14+
15+
}

matches/match.go

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package matches
2+
3+
// Match defines the properties of a PUBG match
4+
type Match struct {
5+
ID string
6+
}

players/player.go

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package players
2+
3+
// Player defines the properties of a PUBG character
4+
type Player struct {
5+
ID string
6+
Name string
7+
}

requests/http.go

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package request
2+
3+
import (
4+
"bytes"
5+
"compress/gzip"
6+
"fmt"
7+
"io"
8+
"net/http"
9+
)
10+
11+
func new(url, key string) (*bytes.Buffer, error) {
12+
// Create the request
13+
req, err := http.NewRequest("GET", "endpoint-url", nil)
14+
15+
if err != nil {
16+
return nil, err
17+
}
18+
19+
// Configure the request
20+
req.Header.Set("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJkNTFmY2Q5MC00YjBiLTAxMzYtNDRjNy0wZTc3YzRhYzg5MmEiLCJpc3MiOiJnYW1lbG9ja2VyIiwiaWF0IjoxNTI4MjE2MjkzLCJwdWIiOiJibHVlaG9sZSIsInRpdGxlIjoicHViZyIsImFwcCI6InB1Ymdfc3RhdF90cmFja2VyLTRhNzk1M2NkLTIzZDktNDJmNy05ZWNjLWJjNTY1YzQwZDcxNyJ9.i5b0XrU11RA8oq4bXRdr4NekwickWaqMt1GHJc71m40")
21+
req.Header.Set("Accept", "application/vnd.api+json")
22+
23+
// Send the request
24+
client := &http.Client{}
25+
response, err := client.Do(req)
26+
27+
if response.StatusCode != 200 {
28+
response.Body.Close()
29+
return nil, fmt.Errorf("HTTP request failed: %s", response.Status)
30+
}
31+
32+
var reader io.ReadCloser
33+
34+
switch response.Header.Get("Content-Encoding") {
35+
case "gzip":
36+
reader, err = gzip.NewReader(response.Body)
37+
if err != nil {
38+
return nil, err
39+
}
40+
default:
41+
reader = response.Body
42+
}
43+
44+
var buffer bytes.Buffer
45+
buffer.ReadFrom(reader)
46+
47+
return &buffer, nil
48+
}

0 commit comments

Comments
 (0)