Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dfa7976c4e | ||
|
|
18eb750ccb | ||
|
|
266dec50de | ||
|
|
220bc5f3d8 | ||
|
|
d224ddcee2 | ||
|
|
b5864632bb | ||
|
|
efd2f2d793 | ||
|
|
9424824416 |
No files matched your search
+131
-43
@@ -13,7 +13,10 @@ concurrency:
|
|||||||
env:
|
env:
|
||||||
GOLANGCI_LINT_VERSION: v2.15.0
|
GOLANGCI_LINT_VERSION: v2.15.0
|
||||||
SQLC_VERSION: v1.31.1
|
SQLC_VERSION: v1.31.1
|
||||||
|
# sha256 of golangci-lint-<version>-linux-amd64.tar.gz from the release's checksums.txt
|
||||||
|
GOLANGCI_LINT_SHA256: 9b7fe6a6bf6334b98decf8d86b11415ea7889afdabdd1959fdce23af2a9ebcea
|
||||||
HELM_VERSION: v3.19.0
|
HELM_VERSION: v3.19.0
|
||||||
|
SHELLCHECK_VERSION: v0.12.0
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
@@ -29,8 +32,24 @@ jobs:
|
|||||||
curl -fsSL "https://go.dev/dl/go${v}.linux-amd64.tar.gz" | tar -C /usr/local -xz
|
curl -fsSL "https://go.dev/dl/go${v}.linux-amd64.tar.gz" | tar -C /usr/local -xz
|
||||||
echo /usr/local/go/bin >> "$GITHUB_PATH"
|
echo /usr/local/go/bin >> "$GITHUB_PATH"
|
||||||
echo "$HOME/go/bin" >> "$GITHUB_PATH"
|
echo "$HOME/go/bin" >> "$GITHUB_PATH"
|
||||||
|
echo "GO_VERSION=$v" >> "$GITHUB_ENV"
|
||||||
|
# Module, build and npm caches live in the runners' S3 cache. Only main
|
||||||
|
# saves them (one entry per commit, expired by the bucket after 7 days);
|
||||||
|
# pull requests and tags restore the newest one from main.
|
||||||
|
- name: Restore caches
|
||||||
|
uses: actions/cache/restore@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
~/.cache/go-build
|
||||||
|
~/.cache/golangci-lint
|
||||||
|
~/.npm
|
||||||
|
key: lint-go${{ env.GO_VERSION }}-${{ hashFiles('go.sum', 'package-lock.json') }}-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
lint-go${{ env.GO_VERSION }}-${{ hashFiles('go.sum', 'package-lock.json') }}-
|
||||||
|
lint-go${{ env.GO_VERSION }}-
|
||||||
- name: Build frontend
|
- name: Build frontend
|
||||||
run: npm ci --no-audit --no-fund && npm run build
|
run: npm ci --no-audit --no-fund --prefer-offline && npm run build
|
||||||
- name: Generated code is up to date
|
- name: Generated code is up to date
|
||||||
run: |
|
run: |
|
||||||
go tool templ generate
|
go tool templ generate
|
||||||
@@ -42,10 +61,15 @@ jobs:
|
|||||||
run: test -z "$(gofmt -l internal cmd tools deploy)" || { gofmt -l internal cmd tools deploy; exit 1; }
|
run: test -z "$(gofmt -l internal cmd tools deploy)" || { gofmt -l internal cmd tools deploy; exit 1; }
|
||||||
- name: go vet
|
- name: go vet
|
||||||
run: go vet ./...
|
run: go vet ./...
|
||||||
|
# The release binary instead of `go install`, which compiled the linter
|
||||||
|
# from source on every run.
|
||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
run: |
|
run: |
|
||||||
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}
|
v="${GOLANGCI_LINT_VERSION#v}"
|
||||||
"$(go env GOPATH)/bin/golangci-lint" run ./...
|
curl -fsSLo /tmp/golangci-lint.tar.gz "https://github.com/golangci/golangci-lint/releases/download/${GOLANGCI_LINT_VERSION}/golangci-lint-${v}-linux-amd64.tar.gz"
|
||||||
|
echo "${GOLANGCI_LINT_SHA256} /tmp/golangci-lint.tar.gz" | sha256sum -c -
|
||||||
|
tar -xzf /tmp/golangci-lint.tar.gz -C /usr/local/bin --strip-components=1 "golangci-lint-${v}-linux-amd64/golangci-lint"
|
||||||
|
golangci-lint run ./...
|
||||||
- name: Helm chart
|
- name: Helm chart
|
||||||
run: |
|
run: |
|
||||||
curl -fsSL "https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz" | tar -xz -C /usr/local/bin --strip-components=1 linux-amd64/helm
|
curl -fsSL "https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz" | tar -xz -C /usr/local/bin --strip-components=1 linux-amd64/helm
|
||||||
@@ -65,8 +89,20 @@ jobs:
|
|||||||
# Debian and Raspberry Pi OS; the test renders and checks it.
|
# Debian and Raspberry Pi OS; the test renders and checks it.
|
||||||
- name: shellcheck
|
- name: shellcheck
|
||||||
run: |
|
run: |
|
||||||
command -v shellcheck >/dev/null || { apt-get update -qq && apt-get install -y -qq shellcheck; }
|
# Static release binary instead of apt-get update + install on every run.
|
||||||
|
curl -fsSL "https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz" \
|
||||||
|
| tar -xJ -C /usr/local/bin --strip-components=1 "shellcheck-${SHELLCHECK_VERSION}/shellcheck"
|
||||||
go test -count=1 -run 'TestScript|TestInstall' -v ./deploy/agent/ | grep -v '^=== RUN'
|
go test -count=1 -run 'TestScript|TestInstall' -v ./deploy/agent/ | grep -v '^=== RUN'
|
||||||
|
- name: Save caches
|
||||||
|
if: github.ref == 'refs/heads/main'
|
||||||
|
uses: actions/cache/save@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
~/.cache/go-build
|
||||||
|
~/.cache/golangci-lint
|
||||||
|
~/.npm
|
||||||
|
key: lint-go${{ env.GO_VERSION }}-${{ hashFiles('go.sum', 'package-lock.json') }}-${{ github.sha }}
|
||||||
|
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -126,8 +162,20 @@ jobs:
|
|||||||
curl -fsSL "https://go.dev/dl/go${v}.linux-amd64.tar.gz" | tar -C /usr/local -xz
|
curl -fsSL "https://go.dev/dl/go${v}.linux-amd64.tar.gz" | tar -C /usr/local -xz
|
||||||
echo /usr/local/go/bin >> "$GITHUB_PATH"
|
echo /usr/local/go/bin >> "$GITHUB_PATH"
|
||||||
echo "$HOME/go/bin" >> "$GITHUB_PATH"
|
echo "$HOME/go/bin" >> "$GITHUB_PATH"
|
||||||
|
echo "GO_VERSION=$v" >> "$GITHUB_ENV"
|
||||||
|
- name: Restore caches
|
||||||
|
uses: actions/cache/restore@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
~/.cache/go-build
|
||||||
|
~/.npm
|
||||||
|
key: test-go${{ env.GO_VERSION }}-${{ hashFiles('go.sum', 'package-lock.json') }}-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
test-go${{ env.GO_VERSION }}-${{ hashFiles('go.sum', 'package-lock.json') }}-
|
||||||
|
test-go${{ env.GO_VERSION }}-
|
||||||
- name: Build frontend
|
- name: Build frontend
|
||||||
run: npm ci --no-audit --no-fund && npm run build
|
run: npm ci --no-audit --no-fund --prefer-offline && npm run build
|
||||||
- name: Prepare database
|
- name: Prepare database
|
||||||
# The same roles and databases as the local environment: the
|
# The same roles and databases as the local environment: the
|
||||||
# application role must not be a superuser, or row-level security
|
# application role must not be a superuser, or row-level security
|
||||||
@@ -136,6 +184,15 @@ jobs:
|
|||||||
- name: Test
|
- name: Test
|
||||||
# Integration tests share one database, so packages run one at a time.
|
# Integration tests share one database, so packages run one at a time.
|
||||||
run: go test -p 1 -count=1 ./...
|
run: go test -p 1 -count=1 ./...
|
||||||
|
- name: Save caches
|
||||||
|
if: github.ref == 'refs/heads/main'
|
||||||
|
uses: actions/cache/save@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
~/.cache/go-build
|
||||||
|
~/.npm
|
||||||
|
key: test-go${{ env.GO_VERSION }}-${{ hashFiles('go.sum', 'package-lock.json') }}-${{ github.sha }}
|
||||||
|
|
||||||
build:
|
build:
|
||||||
# Nothing is built or pushed from code that fails lint or tests; the
|
# Nothing is built or pushed from code that fails lint or tests; the
|
||||||
@@ -155,8 +212,20 @@ jobs:
|
|||||||
curl -fsSL "https://go.dev/dl/go${v}.linux-amd64.tar.gz" | tar -C /usr/local -xz
|
curl -fsSL "https://go.dev/dl/go${v}.linux-amd64.tar.gz" | tar -C /usr/local -xz
|
||||||
echo /usr/local/go/bin >> "$GITHUB_PATH"
|
echo /usr/local/go/bin >> "$GITHUB_PATH"
|
||||||
echo "$HOME/go/bin" >> "$GITHUB_PATH"
|
echo "$HOME/go/bin" >> "$GITHUB_PATH"
|
||||||
|
echo "GO_VERSION=$v" >> "$GITHUB_ENV"
|
||||||
|
- name: Restore caches
|
||||||
|
uses: actions/cache/restore@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
~/.cache/go-build
|
||||||
|
~/.npm
|
||||||
|
key: build-go${{ env.GO_VERSION }}-${{ hashFiles('go.sum', 'package-lock.json') }}-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
build-go${{ env.GO_VERSION }}-${{ hashFiles('go.sum', 'package-lock.json') }}-
|
||||||
|
build-go${{ env.GO_VERSION }}-
|
||||||
- name: Build frontend
|
- name: Build frontend
|
||||||
run: npm ci --no-audit --no-fund && npm run build
|
run: npm ci --no-audit --no-fund --prefer-offline && npm run build
|
||||||
- name: Build binaries
|
- name: Build binaries
|
||||||
id: binaries
|
id: binaries
|
||||||
run: |
|
run: |
|
||||||
@@ -199,38 +268,59 @@ jobs:
|
|||||||
./image -name statuspage -repo "$host/$owner/uptimesebi-statuspage" -port 8082/tcp \
|
./image -name statuspage -repo "$host/$owner/uptimesebi-statuspage" -port 8082/tcp \
|
||||||
-env UPTIME_STATUSPAGE_CACHE_DIR=/var/lib/uptimesebi $variant $flags
|
-env UPTIME_STATUSPAGE_CACHE_DIR=/var/lib/uptimesebi $variant $flags
|
||||||
done
|
done
|
||||||
|
- name: Save caches
|
||||||
|
if: github.ref == 'refs/heads/main'
|
||||||
|
uses: actions/cache/save@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
~/.cache/go-build
|
||||||
|
~/.npm
|
||||||
|
key: build-go${{ env.GO_VERSION }}-${{ hashFiles('go.sum', 'package-lock.json') }}-${{ github.sha }}
|
||||||
|
# The image job packs the amd64 binaries instead of compiling everything again.
|
||||||
|
- name: Hand the binaries to the image job
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: image-context
|
||||||
|
path: |
|
||||||
|
Dockerfile.ci
|
||||||
|
dist/linux_amd64/
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
image:
|
image:
|
||||||
# Kaniko runs rootless from docker:cli, the same way as the other
|
# Builds Dockerfile.ci (the build job's amd64 binaries on distroless)
|
||||||
# repositories on this instance: the default job image has no docker
|
# with the runner's Docker daemon and pushes with crane instead of Kaniko rebuilding frontend
|
||||||
# CLI, and Kaniko's own image lacks what the runner needs to keep a job
|
# and Go from the git context. Images are pushed only from main and tags,
|
||||||
# container alive. Images are pushed only from main and tags, and only
|
# and only once the PACKAGE_TOKEN secret (write:package) exists.
|
||||||
# once the PACKAGE_TOKEN secret (write:package) exists.
|
|
||||||
# The build job's version, so the API reports the release its agent
|
# The build job's version, so the API reports the release its agent
|
||||||
# images are tagged with.
|
# images are tagged with.
|
||||||
needs: build
|
needs: build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
# Node for the artifact action; the Docker CLI is added below.
|
||||||
container:
|
container:
|
||||||
image: docker:cli@sha256:34507eb5069d8be82c95dd3b6987d4250fd5fee49b82e2509b7d7a7030740d6d
|
image: node:24-alpine
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
shell: sh
|
shell: sh
|
||||||
steps:
|
steps:
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: image-context
|
||||||
|
path: ctx
|
||||||
- name: Build (and push from main and tags)
|
- name: Build (and push from main and tags)
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
||||||
PACKAGE_TOKEN: ${{ secrets.PACKAGE_TOKEN }}
|
PACKAGE_TOKEN: ${{ secrets.PACKAGE_TOKEN }}
|
||||||
VERSION: ${{ needs.build.outputs.version }}
|
VERSION: ${{ needs.build.outputs.version }}
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
|
apk add --no-cache docker-cli docker-cli-buildx crane >/dev/null
|
||||||
REGISTRY="${GITHUB_SERVER_URL#*://}"
|
REGISTRY="${GITHUB_SERVER_URL#*://}"
|
||||||
IMAGE="$(printf '%s/%s' "$REGISTRY" "$GITHUB_REPOSITORY" | tr 'A-Z' 'a-z')"
|
IMAGE="$(printf '%s/%s' "$REGISTRY" "$GITHUB_REPOSITORY" | tr 'A-Z' 'a-z')"
|
||||||
SHORT="$(printf '%s' "$GITHUB_SHA" | cut -c1-12)"
|
|
||||||
TAG="$VERSION"
|
TAG="$VERSION"
|
||||||
PUSH="--no-push"
|
TAGS="${IMAGE}:${TAG#v}"
|
||||||
DEST="--destination ${IMAGE}:${TAG#v}"
|
|
||||||
# Channels: edge follows main, beta the newest prerelease, latest
|
# Channels: edge follows main, beta the newest prerelease, latest
|
||||||
# and stable the newest release, X.Y its newest patch.
|
# and stable the newest release, X.Y its newest patch.
|
||||||
|
CHANNELS=""
|
||||||
case "$GITHUB_REF" in
|
case "$GITHUB_REF" in
|
||||||
refs/heads/main) CHANNELS="edge" ;;
|
refs/heads/main) CHANNELS="edge" ;;
|
||||||
refs/tags/v*-beta.*) CHANNELS="beta" ;;
|
refs/tags/v*-beta.*) CHANNELS="beta" ;;
|
||||||
@@ -238,33 +328,31 @@ jobs:
|
|||||||
MINOR="$(printf '%s' "${TAG#v}" | cut -d. -f1-2)"
|
MINOR="$(printf '%s' "${TAG#v}" | cut -d. -f1-2)"
|
||||||
CHANNELS="latest stable $MINOR" ;;
|
CHANNELS="latest stable $MINOR" ;;
|
||||||
esac
|
esac
|
||||||
|
for c in $CHANNELS; do TAGS="$TAGS ${IMAGE}:$c"; done
|
||||||
|
set --
|
||||||
|
for t in $TAGS; do set -- "$@" -t "$t"; done
|
||||||
|
docker build --platform linux/amd64 -f ctx/Dockerfile.ci "$@" ctx
|
||||||
case "$GITHUB_REF" in
|
case "$GITHUB_REF" in
|
||||||
refs/heads/main|refs/tags/v*)
|
refs/heads/main|refs/tags/v*)
|
||||||
if [ -n "${PACKAGE_TOKEN:-}" ]; then
|
if [ -z "${PACKAGE_TOKEN:-}" ]; then
|
||||||
PUSH=""
|
echo "PACKAGE_TOKEN is not set; built without pushing."
|
||||||
for c in $CHANNELS; do DEST="$DEST --destination ${IMAGE}:$c"; done
|
exit 0
|
||||||
else
|
fi
|
||||||
echo "PACKAGE_TOKEN is not set; building without pushing."
|
# crane instead of docker push: on main and tags GITHUB_SERVER_URL is
|
||||||
fi ;;
|
# the in-cluster plain-HTTP address, which the runner's Docker
|
||||||
|
# daemon refuses ("server gave HTTP response to HTTPS client").
|
||||||
|
INSECURE=""
|
||||||
|
case "$GITHUB_SERVER_URL" in http://*) INSECURE="--insecure" ;; esac
|
||||||
|
printf '%s' "$PACKAGE_TOKEN" | crane auth login "$REGISTRY" -u "$GITHUB_ACTOR" --password-stdin $INSECURE
|
||||||
|
FIRST=""
|
||||||
|
for t in $TAGS; do
|
||||||
|
if [ -z "$FIRST" ]; then
|
||||||
|
docker save "$t" -o /tmp/image.tar
|
||||||
|
crane push $INSECURE /tmp/image.tar "$t"
|
||||||
|
FIRST="$t"
|
||||||
|
else
|
||||||
|
crane tag $INSECURE "$FIRST" "${t##*:}"
|
||||||
|
fi
|
||||||
|
done ;;
|
||||||
|
*) echo "Pull request: built without pushing." ;;
|
||||||
esac
|
esac
|
||||||
case "$GITHUB_SERVER_URL" in https://*) PULL=https ;; *) PULL=http ;; esac
|
|
||||||
# Pull requests are built from their head, which Gitea exposes as
|
|
||||||
# refs/pull/<n>/head.
|
|
||||||
REF="$GITHUB_REF"
|
|
||||||
case "$REF" in refs/pull/*/merge) REF="${REF%/merge}/head" ;; esac
|
|
||||||
AUTH="$(printf '%s:%s' "$GITHUB_ACTOR" "${PACKAGE_TOKEN:-none}" | base64 | tr -d '\n')"
|
|
||||||
CFG="$(printf '{"auths":{"%s":{"auth":"%s"}}}' "$REGISTRY" "$AUTH")"
|
|
||||||
docker run --rm \
|
|
||||||
-e GIT_PULL_METHOD="$PULL" \
|
|
||||||
-e GIT_USERNAME="x-access-token" \
|
|
||||||
-e GIT_PASSWORD="$GITEA_TOKEN" \
|
|
||||||
-e CFG="$CFG" \
|
|
||||||
--entrypoint /busybox/sh \
|
|
||||||
gcr.io/kaniko-project/executor:v1.23.2-debug \
|
|
||||||
-c 'mkdir -p /kaniko/.docker && printf %s "$CFG" > /kaniko/.docker/config.json && exec /kaniko/executor "$@"' _ \
|
|
||||||
--context "git://${REGISTRY}/${GITHUB_REPOSITORY}.git#${REF}" \
|
|
||||||
--dockerfile Dockerfile \
|
|
||||||
--build-arg VERSION="$TAG" \
|
|
||||||
--build-arg COMMIT="$SHORT" \
|
|
||||||
$DEST $PUSH \
|
|
||||||
--compressed-caching=false
|
|
||||||
@@ -20,6 +20,19 @@ jobs:
|
|||||||
v="$(awk '/^go /{print $2}' go.mod)"
|
v="$(awk '/^go /{print $2}' go.mod)"
|
||||||
curl -fsSL "https://go.dev/dl/go${v}.linux-amd64.tar.gz" | tar -C /usr/local -xz
|
curl -fsSL "https://go.dev/dl/go${v}.linux-amd64.tar.gz" | tar -C /usr/local -xz
|
||||||
echo /usr/local/go/bin >> "$GITHUB_PATH"
|
echo /usr/local/go/bin >> "$GITHUB_PATH"
|
||||||
|
echo "GO_VERSION=$v" >> "$GITHUB_ENV"
|
||||||
|
# Read-only: the ci workflow's build job saves these caches on main.
|
||||||
|
- name: Restore caches
|
||||||
|
uses: actions/cache/restore@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
~/.cache/go-build
|
||||||
|
~/.npm
|
||||||
|
key: build-go${{ env.GO_VERSION }}-${{ hashFiles('go.sum', 'package-lock.json') }}-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
build-go${{ env.GO_VERSION }}-${{ hashFiles('go.sum', 'package-lock.json') }}-
|
||||||
|
build-go${{ env.GO_VERSION }}-
|
||||||
- name: Check tag
|
- name: Check tag
|
||||||
run: |
|
run: |
|
||||||
go run ./tools/release check "$GITHUB_REF_NAME"
|
go run ./tools/release check "$GITHUB_REF_NAME"
|
||||||
@@ -32,7 +45,7 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
- name: Build frontend
|
- name: Build frontend
|
||||||
run: npm ci --no-audit --no-fund && npm run build
|
run: npm ci --no-audit --no-fund --prefer-offline && npm run build
|
||||||
- name: Package Helm chart
|
- name: Package Helm chart
|
||||||
run: |
|
run: |
|
||||||
curl -fsSL "https://get.helm.sh/helm-v3.19.0-linux-amd64.tar.gz" | tar -xz -C /usr/local/bin --strip-components=1 linux-amd64/helm
|
curl -fsSL "https://get.helm.sh/helm-v3.19.0-linux-amd64.tar.gz" | tar -xz -C /usr/local/bin --strip-components=1 linux-amd64/helm
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# CI image: packs the binaries the build job already compiled (dist/linux_amd64)
|
||||||
|
# instead of building frontend and Go a second time. `make image` and local
|
||||||
|
# builds keep using Dockerfile, which builds everything from source.
|
||||||
|
FROM gcr.io/distroless/static-debian12:nonroot@sha256:afa5c872c891853ca7fcf1f12c3edb23f7eeef36189728842dd51042ff57f7ab
|
||||||
|
COPY dist/linux_amd64/ /usr/local/bin/
|
||||||
|
USER nonroot
|
||||||
|
ENTRYPOINT ["/usr/local/bin/api"]
|
||||||
@@ -27,7 +27,7 @@ require (
|
|||||||
github.com/rabbitmq/amqp091-go v1.17.0
|
github.com/rabbitmq/amqp091-go v1.17.0
|
||||||
github.com/redis/go-redis/v9 v9.23.0
|
github.com/redis/go-redis/v9 v9.23.0
|
||||||
github.com/twmb/franz-go v1.22.3
|
github.com/twmb/franz-go v1.22.3
|
||||||
github.com/twmb/franz-go/pkg/kmsg v1.15.1
|
github.com/twmb/franz-go/pkg/kmsg v1.15.3
|
||||||
github.com/yuin/goldmark v1.8.7
|
github.com/yuin/goldmark v1.8.7
|
||||||
go.mongodb.org/mongo-driver/v2 v2.5.0
|
go.mongodb.org/mongo-driver/v2 v2.5.0
|
||||||
go.uber.org/zap v1.28.0
|
go.uber.org/zap v1.28.0
|
||||||
|
|||||||
@@ -307,8 +307,8 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS
|
|||||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||||
github.com/twmb/franz-go v1.22.3 h1:RHe35s34pKefMLyL+ZYJ6mQVtfFZz4zHDHVkTyACur0=
|
github.com/twmb/franz-go v1.22.3 h1:RHe35s34pKefMLyL+ZYJ6mQVtfFZz4zHDHVkTyACur0=
|
||||||
github.com/twmb/franz-go v1.22.3/go.mod h1:OhbFLkvp6GLcN5daC7I4Q2z0W/rFP16HG+gTbe9CDC4=
|
github.com/twmb/franz-go v1.22.3/go.mod h1:OhbFLkvp6GLcN5daC7I4Q2z0W/rFP16HG+gTbe9CDC4=
|
||||||
github.com/twmb/franz-go/pkg/kmsg v1.15.1 h1:3sj7ekbH33t73nsBcHS0wtp/PyMIViHLNItZrE8V9zM=
|
github.com/twmb/franz-go/pkg/kmsg v1.15.3 h1:fMxHkXdd2WvlwHQ08lpL+roFh0CY+Qd22Ksieur76Nc=
|
||||||
github.com/twmb/franz-go/pkg/kmsg v1.15.1/go.mod h1:sGkGxKexpRLBThFHJLjjywcyfkK09qB/g+X+wFWZQ/A=
|
github.com/twmb/franz-go/pkg/kmsg v1.15.3/go.mod h1:sGkGxKexpRLBThFHJLjjywcyfkK09qB/g+X+wFWZQ/A=
|
||||||
github.com/ugorji/go/codec v1.3.1 h1:waO7eEiFDwidsBN6agj1vJQ4AG7lh2yqXyOXqhgQuyY=
|
github.com/ugorji/go/codec v1.3.1 h1:waO7eEiFDwidsBN6agj1vJQ4AG7lh2yqXyOXqhgQuyY=
|
||||||
github.com/ugorji/go/codec v1.3.1/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
github.com/ugorji/go/codec v1.3.1/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
||||||
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
|
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ package agentapi
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"compress/gzip"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
@@ -172,7 +173,18 @@ func (c *Client) doWith(ctx context.Context, method, path string, header http.He
|
|||||||
case out == nil:
|
case out == nil:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return json.NewDecoder(resp.Body).Decode(out)
|
// Asked for explicitly, a compressed answer is not unpacked by the
|
||||||
|
// transport, nor ever over the stream.
|
||||||
|
var r io.Reader = resp.Body
|
||||||
|
if strings.EqualFold(resp.Header.Get("Content-Encoding"), "gzip") {
|
||||||
|
zr, err := gzip.NewReader(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("agentapi: %s %s: %w", method, path, err)
|
||||||
|
}
|
||||||
|
defer func() { _ = zr.Close() }()
|
||||||
|
r = zr
|
||||||
|
}
|
||||||
|
return json.NewDecoder(r).Decode(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hello identifies the agent and checks connectivity.
|
// Hello identifies the agent and checks connectivity.
|
||||||
|
|||||||
@@ -407,9 +407,10 @@ func (c *Client) PageIfChanged(ctx context.Context, host, slug, checksum string)
|
|||||||
} else {
|
} else {
|
||||||
q.Set("slug", slug)
|
q.Set("slug", slug)
|
||||||
}
|
}
|
||||||
var h http.Header
|
// Pages run to megabytes of JSON that compresses many times over.
|
||||||
|
h := http.Header{"Accept-Encoding": {"gzip"}}
|
||||||
if checksum != "" {
|
if checksum != "" {
|
||||||
h = http.Header{"If-None-Match": {`"` + checksum + `"`}}
|
h.Set("If-None-Match", `"`+checksum+`"`)
|
||||||
}
|
}
|
||||||
var p PageSnapshot
|
var p PageSnapshot
|
||||||
err := c.doWith(ctx, http.MethodGet, "/pages?"+q.Encode(), h, nil, &p)
|
err := c.doWith(ctx, http.MethodGet, "/pages?"+q.Encode(), h, nil, &p)
|
||||||
|
|||||||
+69
-19
@@ -1,6 +1,8 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"compress/gzip"
|
||||||
"context"
|
"context"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
@@ -24,6 +26,7 @@ import (
|
|||||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/authz"
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/authz"
|
||||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/check"
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/check"
|
||||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/evaluate"
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/evaluate"
|
||||||
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/platform"
|
||||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/store"
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/store"
|
||||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/tenant"
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/tenant"
|
||||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/web"
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/web"
|
||||||
@@ -190,7 +193,7 @@ func (s *Server) buildSnapshot(ctx context.Context, page store.StatusPage) (agen
|
|||||||
comp := agentapi.Component{
|
comp := agentapi.Component{
|
||||||
ID: m.MonitorID.String(),
|
ID: m.MonitorID.String(),
|
||||||
Name: name,
|
Name: name,
|
||||||
Uptime: uptime90,
|
Uptime: roundRatio(uptime90),
|
||||||
Days: dayHistory(days[m.MonitorID], now),
|
Days: dayHistory(days[m.MonitorID], now),
|
||||||
}
|
}
|
||||||
switch {
|
switch {
|
||||||
@@ -308,7 +311,7 @@ func buildComponentDetails(
|
|||||||
ts := endHour.Add(-time.Duration(23-i) * time.Hour)
|
ts := endHour.Add(-time.Duration(23-i) * time.Hour)
|
||||||
hours[i] = agentapi.HourBucket{Time: ts, Uptime: -1}
|
hours[i] = agentapi.HourBucket{Time: ts, Uptime: -1}
|
||||||
if b, ok := byHour[ts.Unix()]; ok && b.Total > 0 {
|
if b, ok := byHour[ts.Unix()]; ok && b.Total > 0 {
|
||||||
hours[i].Uptime = float64(b.OK) / float64(b.Total)
|
hours[i].Uptime = roundRatio(float64(b.OK) / float64(b.Total))
|
||||||
hours[i].AvgLatencyMS = int(math.Round(float64(b.Latency)))
|
hours[i].AvgLatencyMS = int(math.Round(float64(b.Latency)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -330,10 +333,10 @@ func buildComponentDetails(
|
|||||||
}
|
}
|
||||||
slices.SortFunc(regs, func(a, b agentapi.ComponentRegion) int { return strings.Compare(a.Name, b.Name) })
|
slices.SortFunc(regs, func(a, b agentapi.ComponentRegion) int { return strings.Compare(a.Name, b.Name) })
|
||||||
return &agentapi.ComponentDetails{
|
return &agentapi.ComponentDetails{
|
||||||
SLA24h: web.Uptime(hourly),
|
SLA24h: roundRatio(web.Uptime(hourly)),
|
||||||
SLA7d: web.Uptime(d7),
|
SLA7d: roundRatio(web.Uptime(d7)),
|
||||||
SLA30d: web.Uptime(d30),
|
SLA30d: roundRatio(web.Uptime(d30)),
|
||||||
SLA90d: uptime90,
|
SLA90d: roundRatio(uptime90),
|
||||||
Hours: hours,
|
Hours: hours,
|
||||||
Regions: regs,
|
Regions: regs,
|
||||||
}
|
}
|
||||||
@@ -350,12 +353,24 @@ func dayHistory(buckets []web.Bucket, now time.Time) []agentapi.Day {
|
|||||||
d := start.AddDate(0, 0, i).Format(time.DateOnly)
|
d := start.AddDate(0, 0, i).Format(time.DateOnly)
|
||||||
out[i] = agentapi.Day{Date: d, Uptime: -1}
|
out[i] = agentapi.Day{Date: d, Uptime: -1}
|
||||||
if b, ok := byDay[d]; ok && b.Total > 0 {
|
if b, ok := byDay[d]; ok && b.Total > 0 {
|
||||||
out[i].Uptime = float64(b.OK) / float64(b.Total)
|
out[i].Uptime = roundRatio(float64(b.OK) / float64(b.Total))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// roundRatio rounds an uptime ratio to six decimals, finer than any page
|
||||||
|
// shows it. Unrounded, a ratio takes up to 18 characters, and a large page
|
||||||
|
// holds 90 of them for every component. A ratio below 1 stays below 1, so
|
||||||
|
// a page never shows 100% for a component that failed.
|
||||||
|
func roundRatio(r float64) float64 {
|
||||||
|
v := math.Round(r*1e6) / 1e6
|
||||||
|
if v >= 1 && r < 1 {
|
||||||
|
return 0.999999
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
// agentPage serves a page snapshot to status page servers. Org-owned
|
// agentPage serves a page snapshot to status page servers. Org-owned
|
||||||
// servers only receive their own org's pages.
|
// servers only receive their own org's pages.
|
||||||
func (s *Server) agentPage(c *gin.Context) {
|
func (s *Server) agentPage(c *gin.Context) {
|
||||||
@@ -385,36 +400,71 @@ func (s *Server) agentPage(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
// The server sends the checksum of its copy; an unchanged page is not
|
// The server sends the checksum of its copy; an unchanged page is not
|
||||||
// sent again.
|
// sent again.
|
||||||
etag := `"` + snap.Checksum() + `"`
|
c.Header("ETag", snap.etag)
|
||||||
c.Header("ETag", etag)
|
if c.GetHeader("If-None-Match") == snap.etag {
|
||||||
if c.GetHeader("If-None-Match") == etag {
|
|
||||||
c.Status(http.StatusNotModified)
|
c.Status(http.StatusNotModified)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, snap)
|
// The encoded page is shared by everyone asking for it at once; large
|
||||||
|
// pages run to megabytes, encoding them per request ran the API out of
|
||||||
|
// memory.
|
||||||
|
body := snap.json
|
||||||
|
if platform.AcceptsGzip(c.GetHeader("Accept-Encoding")) {
|
||||||
|
c.Header("Content-Encoding", "gzip")
|
||||||
|
body = snap.gzip
|
||||||
|
}
|
||||||
|
c.Data(http.StatusOK, "application/json; charset=utf-8", body)
|
||||||
|
}
|
||||||
|
|
||||||
|
// encodedSnapshot is a page snapshot as sent to status page servers.
|
||||||
|
type encodedSnapshot struct {
|
||||||
|
etag string
|
||||||
|
json []byte
|
||||||
|
gzip []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// encodeSnapshot encodes snap once, as JSON and gzipped JSON.
|
||||||
|
func encodeSnapshot(snap agentapi.PageSnapshot) (encodedSnapshot, error) {
|
||||||
|
raw, err := json.Marshal(snap)
|
||||||
|
if err != nil {
|
||||||
|
return encodedSnapshot{}, err
|
||||||
|
}
|
||||||
|
var buf bytes.Buffer
|
||||||
|
zw := gzip.NewWriter(&buf)
|
||||||
|
if _, err := zw.Write(raw); err != nil {
|
||||||
|
return encodedSnapshot{}, err
|
||||||
|
}
|
||||||
|
if err := zw.Close(); err != nil {
|
||||||
|
return encodedSnapshot{}, err
|
||||||
|
}
|
||||||
|
return encodedSnapshot{etag: `"` + snap.Checksum() + `"`, json: raw, gzip: buf.Bytes()}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// snapshotTimeout bounds a shared snapshot build, which outlives the
|
// snapshotTimeout bounds a shared snapshot build, which outlives the
|
||||||
// request that started it.
|
// request that started it.
|
||||||
const snapshotTimeout = time.Minute
|
const snapshotTimeout = time.Minute
|
||||||
|
|
||||||
// sharedSnapshot builds page once for all status page servers asking for it
|
// sharedSnapshot builds and encodes page once for all status page servers
|
||||||
// at the same time, as they do when told that it changed. A server giving
|
// asking for it at the same time, as they do when told that it changed. A
|
||||||
// up does not cancel the build for the others.
|
// server giving up does not cancel the build for the others.
|
||||||
func (s *Server) sharedSnapshot(ctx context.Context, page store.StatusPage) (agentapi.PageSnapshot, error) {
|
func (s *Server) sharedSnapshot(ctx context.Context, page store.StatusPage) (encodedSnapshot, error) {
|
||||||
ch := s.snapshots.DoChan(page.ID.String(), func() (any, error) {
|
ch := s.snapshots.DoChan(page.ID.String(), func() (any, error) {
|
||||||
ctx, cancel := context.WithTimeout(context.WithoutCancel(ctx), snapshotTimeout)
|
ctx, cancel := context.WithTimeout(context.WithoutCancel(ctx), snapshotTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
return s.buildSnapshot(ctx, page)
|
snap, err := s.buildSnapshot(ctx, page)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return encodeSnapshot(snap)
|
||||||
})
|
})
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return agentapi.PageSnapshot{}, ctx.Err()
|
return encodedSnapshot{}, ctx.Err()
|
||||||
case r := <-ch:
|
case r := <-ch:
|
||||||
if r.Err != nil {
|
if r.Err != nil {
|
||||||
return agentapi.PageSnapshot{}, r.Err
|
return encodedSnapshot{}, r.Err
|
||||||
}
|
}
|
||||||
return r.Val.(agentapi.PageSnapshot), nil
|
return r.Val.(encodedSnapshot), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestRoundRatio(t *testing.T) {
|
||||||
|
for _, c := range []struct{ in, want float64 }{
|
||||||
|
{1, 1},
|
||||||
|
{-1, -1},
|
||||||
|
{0, 0},
|
||||||
|
{0.99930555555556, 0.999306},
|
||||||
|
{0.99, 0.99},
|
||||||
|
// One failure in millions still is not 100%.
|
||||||
|
{0.9999997, 0.999999},
|
||||||
|
} {
|
||||||
|
if got := roundRatio(c.in); got != c.want {
|
||||||
|
t.Errorf("roundRatio(%v) = %v, want %v", c.in, got, c.want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package api_test
|
package api_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"compress/gzip"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
@@ -9,6 +10,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"slices"
|
"slices"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@@ -481,3 +483,75 @@ func TestStatusPageGroupsAndDetails(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestAgentPageEncoding fetches a page as a status page server would, with
|
||||||
|
// and without gzip, and through both the HTTP API and the client.
|
||||||
|
func TestAgentPageEncoding(t *testing.T) {
|
||||||
|
e := newEnv(t)
|
||||||
|
ctx := context.Background()
|
||||||
|
owner := e.browser(t)
|
||||||
|
owner.signup("o@"+uniq("enc")+".test", uniq("enc-"))
|
||||||
|
slug := uniq("enc-")
|
||||||
|
_, body := owner.do("POST", "/api/v1/org/statuspages", map[string]any{"slug": slug, "title": "Encoded"})
|
||||||
|
owner.do("PUT", "/api/v1/org/statuspages/"+body["id"].(string), map[string]any{"slug": slug, "title": "Encoded", "published": true})
|
||||||
|
|
||||||
|
tok, params := api.NewAgentToken(nil, "statuspage", "sp-"+uuid.NewString()[:6], nil)
|
||||||
|
if err := tenant.New(e.dbPool).Tx(ctx, tenant.System(), func(q *store.Queries) error {
|
||||||
|
_, err := q.CreateAgent(ctx, params)
|
||||||
|
return err
|
||||||
|
}); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
// No transparent decompression: the test sees what the API sends.
|
||||||
|
hc := &http.Client{Transport: &http.Transport{DisableCompression: true, TLSClientConfig: e.srv.Client().Transport.(*http.Transport).TLSClientConfig}}
|
||||||
|
get := func(header map[string]string) *http.Response {
|
||||||
|
t.Helper()
|
||||||
|
req, _ := http.NewRequest(http.MethodGet, e.srv.URL+"/agent/v1/pages?slug="+slug, nil)
|
||||||
|
req.Header.Set("Authorization", "Bearer "+tok)
|
||||||
|
req.Header.Set(agentapi.VersionHeader, strconv.Itoa(agentapi.Version))
|
||||||
|
req.Header.Set(agentapi.InstanceHeader, uuid.NewString())
|
||||||
|
for k, v := range header {
|
||||||
|
req.Header.Set(k, v)
|
||||||
|
}
|
||||||
|
resp, err := hc.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Cleanup(func() { _ = resp.Body.Close() })
|
||||||
|
return resp
|
||||||
|
}
|
||||||
|
|
||||||
|
plain := get(nil)
|
||||||
|
raw, _ := io.ReadAll(plain.Body)
|
||||||
|
var snap agentapi.PageSnapshot
|
||||||
|
if plain.StatusCode != http.StatusOK || plain.Header.Get("Content-Encoding") != "" || json.Unmarshal(raw, &snap) != nil || snap.Title != "Encoded" {
|
||||||
|
t.Fatalf("plain page = %d %q %.200s", plain.StatusCode, plain.Header.Get("Content-Encoding"), raw)
|
||||||
|
}
|
||||||
|
etag := plain.Header.Get("ETag")
|
||||||
|
if etag != `"`+snap.Checksum()+`"` {
|
||||||
|
t.Errorf("ETag = %s, want the checksum %s", etag, snap.Checksum())
|
||||||
|
}
|
||||||
|
|
||||||
|
packed := get(map[string]string{"Accept-Encoding": "gzip"})
|
||||||
|
if packed.Header.Get("Content-Encoding") != "gzip" || packed.Header.Get("ETag") != etag {
|
||||||
|
t.Fatalf("gzip page encoding %q, ETag %q; want gzip and %s", packed.Header.Get("Content-Encoding"), packed.Header.Get("ETag"), etag)
|
||||||
|
}
|
||||||
|
zr, err := gzip.NewReader(packed.Body)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
var unpacked agentapi.PageSnapshot
|
||||||
|
if err := json.NewDecoder(zr).Decode(&unpacked); err != nil || unpacked.Checksum() != snap.Checksum() {
|
||||||
|
t.Errorf("the gzipped page differs from the plain one: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if st := get(map[string]string{"If-None-Match": etag, "Accept-Encoding": "gzip"}).StatusCode; st != http.StatusNotModified {
|
||||||
|
t.Errorf("page with the current ETag = %d, want 304", st)
|
||||||
|
}
|
||||||
|
|
||||||
|
// The client asks for gzip and unpacks it, over plain HTTP too.
|
||||||
|
client := agentapi.NewClient(e.srv.URL, tok, uuid.New(), "test").WithHTTPClient(e.srv.Client())
|
||||||
|
if got, err := client.Page(ctx, "", slug); err != nil || got.Checksum() != snap.Checksum() {
|
||||||
|
t.Errorf("client Page() = %q, %v; want the same page", got.Title, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -38,6 +38,10 @@ func Compress() gin.HandlerFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AcceptsGzip reports whether an Accept-Encoding header allows gzip, for
|
||||||
|
// handlers that send content compressed ahead of time.
|
||||||
|
func AcceptsGzip(header string) bool { return acceptsGzip(header) }
|
||||||
|
|
||||||
// acceptsGzip reports whether an Accept-Encoding header allows gzip.
|
// acceptsGzip reports whether an Accept-Encoding header allows gzip.
|
||||||
func acceptsGzip(header string) bool {
|
func acceptsGzip(header string) bool {
|
||||||
for _, part := range strings.Split(header, ",") {
|
for _, part := range strings.Split(header, ",") {
|
||||||
|
|||||||
Reference in new issue
Block a user