Skip to content

Commit b1e2421

Browse files
committed
modernize build, set user-agent header for forum listing
1 parent 7e2d631 commit b1e2421

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
!*.go
33
!server/*
44
!go.mod
5-
!go.lock
5+
!go.sum

Dockerfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ FROM golang:1.20-alpine
22

33
WORKDIR /go/src/github.com/ccbrown/gggtracker
44

5-
RUN apk add --no-cache git g++
6-
75
ADD . .
8-
RUN go generate ./...
96
RUN go vet .
107
RUN go test -v ./...
118
RUN go build .

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This is the repository for [gggtracker.com](https://gggtracker.com). If there's
44

55
### Development
66

7-
If you have Go installed, you can develop and run the server in the usual way: `go get ./... && go generate ./... && go run main.go`
7+
If you have Go installed, you can develop and run the server in the usual way: `go run main.go`
88

99
![Development](development.gif)
1010

server/localization.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,23 @@ func (l *Locale) RefreshForumIds() error {
5656
client := http.Client{
5757
Timeout: time.Second * 10,
5858
}
59-
resp, err := client.Get(fmt.Sprintf("https://%v/forum", l.ForumHost()))
59+
60+
req, err := http.NewRequest("GET", fmt.Sprintf("https://%v/forum", l.ForumHost()), nil)
61+
if err != nil {
62+
return err
63+
}
64+
req.Header.Set("User-Agent", UserAgent)
65+
66+
resp, err := client.Do(req)
6067
if err != nil {
6168
return err
6269
}
6370
defer resp.Body.Close()
6471

72+
if resp.StatusCode != http.StatusOK {
73+
return fmt.Errorf("unexpected status code: %v", resp.StatusCode)
74+
}
75+
6576
doc, err := goquery.NewDocumentFromReader(resp.Body)
6677
if err != nil {
6778
return err

0 commit comments

Comments
 (0)