mirror of
https://github.com/jimeh/casecmp.git
synced 2026-02-19 10:26:40 +00:00
Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e0eef21fd2 | |||
|
|
bbca419be6
|
||
|
f944c6e7e8
|
|||
|
6603db3e69
|
|||
|
1edbd2a7af
|
|||
|
75ddccedf3
|
|||
|
8791b80ff6
|
|||
|
e53f79024b
|
|||
|
3813304041
|
|||
| 7863eddb09 | |||
|
8ccc38c186
|
|||
|
84da611833
|
|||
|
7a152b06b2
|
|||
|
b7f4d11fc9
|
|||
|
cdaaec6b0b
|
|||
|
51717ebcd1
|
|||
|
7df597a842
|
|||
|
732c588dbc
|
|||
|
1816e93170
|
|||
|
29902b2e8e
|
|||
|
36e0863cc3
|
|||
|
5471ff95a7
|
|||
|
4c89c92f75
|
|||
| d19eed020c | |||
|
aef3e832f5
|
@@ -1,57 +0,0 @@
|
|||||||
version: 2
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
docker:
|
|
||||||
- image: circleci/golang:1.16
|
|
||||||
working_directory: /go/src/github.com/jimeh/casecmp
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- run:
|
|
||||||
name: Install dependencies
|
|
||||||
command: go mod download
|
|
||||||
- run:
|
|
||||||
name: Build binary
|
|
||||||
command: make
|
|
||||||
- run:
|
|
||||||
name: Start service
|
|
||||||
command: ./bin/casecmp --port=8080
|
|
||||||
background: true
|
|
||||||
- run:
|
|
||||||
name: Validate service is working
|
|
||||||
command: |
|
|
||||||
curl --retry 10 --retry-delay 1 --retry-connrefused \
|
|
||||||
http://localhost:8080/
|
|
||||||
release:
|
|
||||||
docker:
|
|
||||||
- image: circleci/golang:1.16
|
|
||||||
working_directory: /go/src/github.com/jimeh/casecmp
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- run: curl -sL https://git.io/goreleaser | bash
|
|
||||||
|
|
||||||
workflows:
|
|
||||||
version: 2
|
|
||||||
build:
|
|
||||||
jobs:
|
|
||||||
- build:
|
|
||||||
filters:
|
|
||||||
branches:
|
|
||||||
only: /.*/
|
|
||||||
tags:
|
|
||||||
ignore: /^v[0-9]+(\.[0-9]+)*/
|
|
||||||
build-and-release:
|
|
||||||
jobs:
|
|
||||||
- build:
|
|
||||||
filters:
|
|
||||||
branches:
|
|
||||||
ignore: /.*/
|
|
||||||
tags:
|
|
||||||
only: /^v[0-9]+(\.[0-9]+)*/
|
|
||||||
- release:
|
|
||||||
requires:
|
|
||||||
- build
|
|
||||||
filters:
|
|
||||||
branches:
|
|
||||||
ignore: /.*/
|
|
||||||
tags:
|
|
||||||
only: /^v[0-9]+(\.[0-9]+)*/
|
|
||||||
60
.github/workflows/ci.yml
vendored
Normal file
60
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
---
|
||||||
|
name: CI
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: 1.19
|
||||||
|
- name: Install dependencies
|
||||||
|
run: go mod download
|
||||||
|
- name: Build binary
|
||||||
|
run: make
|
||||||
|
- name: Run and make request
|
||||||
|
run: |
|
||||||
|
./bin/casecmp --port=8080 &
|
||||||
|
curl --silent --retry 10 --retry-delay 1 --retry-connrefused \
|
||||||
|
http://localhost:8080/
|
||||||
|
|
||||||
|
release-please:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [build]
|
||||||
|
if: github.ref == 'refs/heads/main'
|
||||||
|
steps:
|
||||||
|
- uses: google-github-actions/release-please-action@v3
|
||||||
|
id: release-please
|
||||||
|
with:
|
||||||
|
command: manifest
|
||||||
|
- if: ${{ steps.release-please.outputs.release_created }}
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- if: ${{ steps.release-please.outputs.release_created }}
|
||||||
|
name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
- if: ${{ steps.release-please.outputs.release_created }}
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
- if: ${{ steps.release-please.outputs.release_created }}
|
||||||
|
name: Docker Login
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- if: ${{ steps.release-please.outputs.release_created }}
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: 1.19
|
||||||
|
- if: ${{ steps.release-please.outputs.release_created }}
|
||||||
|
name: Run GoReleaser
|
||||||
|
uses: goreleaser/goreleaser-action@v2
|
||||||
|
with:
|
||||||
|
version: latest
|
||||||
|
args: release --rm-dist
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -10,17 +10,18 @@ builds:
|
|||||||
ldflags:
|
ldflags:
|
||||||
- "-s -w -X main.version={{ .Version }} -X main.commit={{ .Commit }}"
|
- "-s -w -X main.version={{ .Version }} -X main.commit={{ .Commit }}"
|
||||||
goos:
|
goos:
|
||||||
- darwin
|
- "darwin"
|
||||||
- freebsd
|
- "freebsd"
|
||||||
- linux
|
- "linux"
|
||||||
- windows
|
- "windows"
|
||||||
goarch:
|
goarch:
|
||||||
- amd64
|
- "amd64"
|
||||||
- 386
|
- "386"
|
||||||
- arm
|
- "arm"
|
||||||
|
- "arm64"
|
||||||
goarm:
|
goarm:
|
||||||
- 6
|
- "6"
|
||||||
- 7
|
- "7"
|
||||||
|
|
||||||
archives:
|
archives:
|
||||||
- format: tar.gz
|
- format: tar.gz
|
||||||
@@ -30,20 +31,76 @@ archives:
|
|||||||
format_overrides:
|
format_overrides:
|
||||||
- goos: windows
|
- goos: windows
|
||||||
format: zip
|
format: zip
|
||||||
replacements:
|
|
||||||
darwin: Darwin
|
|
||||||
linux: Linux
|
|
||||||
windows: Windows
|
|
||||||
386: i386
|
|
||||||
amd64: x86_64
|
|
||||||
|
|
||||||
checksum:
|
checksum:
|
||||||
name_template: "checksums.txt"
|
name_template: "checksums.txt"
|
||||||
snapshot:
|
snapshot:
|
||||||
name_template: "{{ .Tag }}-next"
|
name_template: "{{ .Tag }}-next"
|
||||||
|
|
||||||
changelog:
|
changelog:
|
||||||
sort: asc
|
skip: true
|
||||||
filters:
|
|
||||||
exclude:
|
dockers:
|
||||||
- "^docs:"
|
- image_templates:
|
||||||
- "^test:"
|
- "ghcr.io/jimeh/casecmp:{{ .Version }}-amd64"
|
||||||
|
- "ghcr.io/jimeh/casecmp:latest-amd64"
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
use: buildx
|
||||||
|
goos: linux
|
||||||
|
goarch: amd64
|
||||||
|
build_flag_templates:
|
||||||
|
- "--platform=linux/amd64"
|
||||||
|
- image_templates:
|
||||||
|
- "ghcr.io/jimeh/casecmp:{{ .Version }}-386"
|
||||||
|
- "ghcr.io/jimeh/casecmp:latest-386"
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
use: buildx
|
||||||
|
goos: linux
|
||||||
|
goarch: "386"
|
||||||
|
build_flag_templates:
|
||||||
|
- "--platform=linux/386"
|
||||||
|
- image_templates:
|
||||||
|
- "ghcr.io/jimeh/casecmp:{{ .Version }}-arm64"
|
||||||
|
- "ghcr.io/jimeh/casecmp:latest-arm64"
|
||||||
|
use: buildx
|
||||||
|
goos: linux
|
||||||
|
goarch: arm64
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
build_flag_templates:
|
||||||
|
- "--platform=linux/arm64"
|
||||||
|
- image_templates:
|
||||||
|
- "ghcr.io/jimeh/casecmp:{{ .Version }}-armv6"
|
||||||
|
- "ghcr.io/jimeh/casecmp:latest-armv6"
|
||||||
|
use: buildx
|
||||||
|
goos: linux
|
||||||
|
goarch: arm
|
||||||
|
goarm: "6"
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
build_flag_templates:
|
||||||
|
- "--platform=linux/arm/v6"
|
||||||
|
- image_templates:
|
||||||
|
- "ghcr.io/jimeh/casecmp:{{ .Version }}-armv7"
|
||||||
|
- "ghcr.io/jimeh/casecmp:latest-armv7"
|
||||||
|
use: buildx
|
||||||
|
goos: linux
|
||||||
|
goarch: arm
|
||||||
|
goarm: "7"
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
build_flag_templates:
|
||||||
|
- "--platform=linux/arm/v7"
|
||||||
|
|
||||||
|
docker_manifests:
|
||||||
|
- name_template: ghcr.io/jimeh/casecmp:{{ .Version }}
|
||||||
|
image_templates:
|
||||||
|
- ghcr.io/jimeh/casecmp:{{ .Version }}-amd64
|
||||||
|
- ghcr.io/jimeh/casecmp:{{ .Version }}-386
|
||||||
|
- ghcr.io/jimeh/casecmp:{{ .Version }}-arm64
|
||||||
|
- ghcr.io/jimeh/casecmp:{{ .Version }}-armv6
|
||||||
|
- ghcr.io/jimeh/casecmp:{{ .Version }}-armv7
|
||||||
|
- name_template: ghcr.io/jimeh/casecmp:latest
|
||||||
|
image_templates:
|
||||||
|
- ghcr.io/jimeh/casecmp:latest-amd64
|
||||||
|
- ghcr.io/jimeh/casecmp:latest-386
|
||||||
|
- ghcr.io/jimeh/casecmp:latest-arm64
|
||||||
|
- ghcr.io/jimeh/casecmp:latest-armv6
|
||||||
|
- ghcr.io/jimeh/casecmp:latest-armv7
|
||||||
|
|||||||
3
.release-please-manifest.json
Normal file
3
.release-please-manifest.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
".": "1.5.0"
|
||||||
|
}
|
||||||
22
CHANGELOG.md
Normal file
22
CHANGELOG.md
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## [1.5.0](https://github.com/jimeh/casecmp/compare/v1.4.0...v1.5.0) (2022-11-14)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **deps:** upgrade to Go 1.19 ([75ddcce](https://github.com/jimeh/casecmp/commit/75ddccedf330497c0e04cd4b7f0679e647b8e190))
|
||||||
|
|
||||||
|
## [1.4.0](https://github.com/jimeh/casecmp/compare/v1.3.0...v1.4.0) (2022-05-24)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* compare on GET requests with non-empty query string ([cdaaec6](https://github.com/jimeh/casecmp/commit/cdaaec6b0b763141476562047578844e6105ec7a))
|
||||||
|
|
||||||
|
## [1.3.0](https://github.com/jimeh/casecmp/compare/v1.2.3...v1.3.0) (2022-02-13)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **release:** setup for publishing docker images to ghcr ([1816e93](https://github.com/jimeh/casecmp/commit/1816e93170bb725f8da073b91070a981dd039fad))
|
||||||
14
Dockerfile
14
Dockerfile
@@ -1,17 +1,5 @@
|
|||||||
FROM golang:1.16-alpine as builder
|
|
||||||
RUN apk add --no-cache \
|
|
||||||
git
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
COPY . /app
|
|
||||||
RUN env CGO_ENABLED=0 \
|
|
||||||
go build -a -o /casecmp -ldflags "-s -w \
|
|
||||||
-X main.version=$(cat VERSION) \
|
|
||||||
-X main.commit=$(git show --format='%h' --no-patch) \
|
|
||||||
-X main.date=$(date +%Y-%m-%dT%T%z)"
|
|
||||||
|
|
||||||
FROM scratch
|
FROM scratch
|
||||||
COPY --from=builder /casecmp /
|
COPY ./casecmp /
|
||||||
ENV PORT 8080
|
ENV PORT 8080
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
|
|||||||
9
go.mod
9
go.mod
@@ -1,10 +1,11 @@
|
|||||||
module github.com/jimeh/casecmp
|
module github.com/jimeh/casecmp
|
||||||
|
|
||||||
go 1.16
|
go 1.19
|
||||||
|
|
||||||
|
require gopkg.in/alecthomas/kingpin.v2 v2.2.6
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect
|
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
|
||||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect
|
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
|
||||||
github.com/stretchr/testify v1.7.0 // indirect
|
github.com/stretchr/testify v1.7.0 // indirect
|
||||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6
|
|
||||||
)
|
)
|
||||||
|
|||||||
10
go.sum
10
go.sum
@@ -1,16 +1,18 @@
|
|||||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU=
|
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=
|
||||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=
|
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAuRjVTiNNhvNRfY2Wxp9nhfyel4rklc=
|
||||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE=
|
||||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
|
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
|
||||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
|||||||
50
main.go
50
main.go
@@ -7,6 +7,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"gopkg.in/alecthomas/kingpin.v2"
|
"gopkg.in/alecthomas/kingpin.v2"
|
||||||
)
|
)
|
||||||
@@ -44,13 +45,26 @@ Case-insensitive string comparison, as an API. Because ¯\_(ツ)_/¯
|
|||||||
|
|
||||||
Example usage:
|
Example usage:
|
||||||
curl -X POST -F "a=Foo Bar" -F "b=FOO BAR" %s://%s/
|
curl -X POST -F "a=Foo Bar" -F "b=FOO BAR" %s://%s/
|
||||||
curl -X POST "%s://%s/?a=Foo+Bar&b=FOO+BAR"`,
|
curl -X GET "%s://%s/?a=Foo+Bar&b=FOO+BAR"
|
||||||
|
`,
|
||||||
name, version, scheme, r.Host, scheme, r.Host)
|
name, version, scheme, r.Host, scheme, r.Host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func aboutHandler(w http.ResponseWriter, _ *http.Request) {
|
||||||
|
_, err := fmt.Fprintf(w,
|
||||||
|
`%s %s
|
||||||
|
|
||||||
|
https://github.com/jimeh/casecmp
|
||||||
|
`,
|
||||||
|
name, version)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func casecmpHandler(w http.ResponseWriter, r *http.Request) {
|
func casecmpHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
a := r.FormValue("a")
|
a := r.FormValue("a")
|
||||||
b := r.FormValue("b")
|
b := r.FormValue("b")
|
||||||
@@ -59,22 +73,24 @@ func casecmpHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
if strings.EqualFold(string(a), string(b)) {
|
if strings.EqualFold(string(a), string(b)) {
|
||||||
resp = "1"
|
resp = "1"
|
||||||
}
|
}
|
||||||
_, err := fmt.Fprintf(w, resp)
|
_, err := fmt.Fprint(w, resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func rootHandler(w http.ResponseWriter, r *http.Request) {
|
func handler(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.URL.Path != "/" {
|
switch r.URL.Path {
|
||||||
http.NotFound(w, r)
|
case "/":
|
||||||
return
|
if r.Method != "GET" || r.URL.RawQuery != "" {
|
||||||
}
|
casecmpHandler(w, r)
|
||||||
|
return
|
||||||
if r.Method == "GET" {
|
}
|
||||||
indexHandler(w, r)
|
indexHandler(w, r)
|
||||||
} else {
|
case "/about":
|
||||||
casecmpHandler(w, r)
|
aboutHandler(w, r)
|
||||||
|
default:
|
||||||
|
http.NotFound(w, r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,8 +106,6 @@ func printVersion() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func startServer() {
|
func startServer() {
|
||||||
http.HandleFunc("/", rootHandler)
|
|
||||||
|
|
||||||
if *portFlag == "" {
|
if *portFlag == "" {
|
||||||
envPort := os.Getenv("PORT")
|
envPort := os.Getenv("PORT")
|
||||||
if envPort != "" {
|
if envPort != "" {
|
||||||
@@ -107,7 +121,15 @@ func startServer() {
|
|||||||
|
|
||||||
address := *bindFlag + ":" + *portFlag
|
address := *bindFlag + ":" + *portFlag
|
||||||
fmt.Printf("Listening on %s\n", address)
|
fmt.Printf("Listening on %s\n", address)
|
||||||
log.Fatal(http.ListenAndServe(address, nil))
|
srv := &http.Server{
|
||||||
|
ReadTimeout: 5 * time.Second,
|
||||||
|
WriteTimeout: 5 * time.Second,
|
||||||
|
IdleTimeout: 30 * time.Second,
|
||||||
|
Handler: http.HandlerFunc(handler),
|
||||||
|
Addr: address,
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Fatal(srv.ListenAndServe())
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
18
release-please-config.json
Normal file
18
release-please-config.json
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"bootstrap-sha": "b7f4d11fc99f9ffa85376c5757d8dd8c6341c38a",
|
||||||
|
"last-release-sha": "b7f4d11fc99f9ffa85376c5757d8dd8c6341c38a",
|
||||||
|
"release-type": "go",
|
||||||
|
"bump-minor-pre-major": true,
|
||||||
|
"bump-patch-for-minor-pre-major": true,
|
||||||
|
"packages": {
|
||||||
|
".": {
|
||||||
|
"changelog-path": "CHANGELOG.md",
|
||||||
|
"bump-minor-pre-major": false,
|
||||||
|
"bump-patch-for-minor-pre-major": false,
|
||||||
|
"draft": false,
|
||||||
|
"prerelease": false,
|
||||||
|
"extra-files": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user