Ублажил линтер

master
Andrey Ivanov 2020-11-06 20:07:17 +03:00 committed by tiburon
parent c98a644ccd
commit 9892ee6dd5
4 changed files with 18 additions and 2 deletions

View File

@ -31,6 +31,6 @@ jobs:
script:
- make lint
- make unit-test
- make integration-test
- make build
- make docker-build
if: (type = push) OR (type = pull_request)

11
Dockerfile Normal file
View File

@ -0,0 +1,11 @@
FROM golang:1.14 as builder
RUN mkdir -p /app
WORKDIR /app
COPY . .
RUN go get -d ./cmd/.
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o previewer ./cmd/.
FROM alpine:latest
WORKDIR /
COPY --from=builder /app/previewer .
CMD ["/previewer"]

View File

@ -1,3 +1,6 @@
docker-build:
sudo docker build -t previewer .
build:
go build -o bin ./cmd/main.go

View File

@ -45,7 +45,9 @@ func (q Query) id() string {
func (q Query) fromOrigin(headers http.Header, timeout time.Duration) ([]byte, *http.Response, error) {
client := &http.Client{Timeout: timeout}
req, err := http.NewRequestWithContext(context.Background(), "GET", "http://"+q.URL.Host+q.URL.Path, nil)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
req, err := http.NewRequestWithContext(ctx, "GET", "http://"+q.URL.Host+q.URL.Path, nil)
if err != nil {
return nil, nil, fmt.Errorf("can't create request: %w", err)
}