Skip to content

Commit 897ac4b

Browse files
committed
chore(deps): Bumping httputils to v4
Signed-off-by: Vincent Boutour <[email protected]>
1 parent 26dd7fd commit 897ac4b

File tree

7 files changed

+61
-32
lines changed

7 files changed

+61
-32
lines changed

README.md

+24-10
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ Following variables are required for CI:
3030
```bash
3131
Usage of api:
3232
-address string
33-
[http] Listen address {API_ADDRESS}
33+
[server] Listen address {API_ADDRESS}
3434
-cert string
35-
[http] Certificate file {API_CERT}
35+
[server] Certificate file {API_CERT}
3636
-corsCredentials
3737
[cors] Access-Control-Allow-Credentials {API_CORS_CREDENTIALS}
3838
-corsExpose string
@@ -52,9 +52,9 @@ Usage of api:
5252
-hsts
5353
[owasp] Indicate Strict Transport Security {API_HSTS} (default true)
5454
-idleTimeout string
55-
[http] Idle Timeout {API_IDLE_TIMEOUT} (default "2m")
55+
[server] Idle Timeout {API_IDLE_TIMEOUT} (default "2m")
5656
-key string
57-
[http] Key file {API_KEY}
57+
[server] Key file {API_KEY}
5858
-location string
5959
[hello] TimeZone for displaying current time {API_LOCATION} (default "Europe/Paris")
6060
-loggerJson
@@ -70,19 +70,33 @@ Usage of api:
7070
-okStatus int
7171
[http] Healthy HTTP Status code {API_OK_STATUS} (default 204)
7272
-port uint
73-
[http] Listen port {API_PORT} (default 1080)
73+
[server] Listen port {API_PORT} (default 1080)
74+
-prometheusAddress string
75+
[prometheus] Listen address {API_PROMETHEUS_ADDRESS}
76+
-prometheusCert string
77+
[prometheus] Certificate file {API_PROMETHEUS_CERT}
78+
-prometheusIdleTimeout string
79+
[prometheus] Idle Timeout {API_PROMETHEUS_IDLE_TIMEOUT} (default "10s")
7480
-prometheusIgnore string
7581
[prometheus] Ignored path prefixes for metrics, comma separated {API_PROMETHEUS_IGNORE}
76-
-prometheusPath string
77-
[prometheus] Path for exposing metrics {API_PROMETHEUS_PATH} (default "/metrics")
82+
-prometheusKey string
83+
[prometheus] Key file {API_PROMETHEUS_KEY}
84+
-prometheusPort uint
85+
[prometheus] Listen port {API_PROMETHEUS_PORT} (default 9090)
86+
-prometheusReadTimeout string
87+
[prometheus] Read Timeout {API_PROMETHEUS_READ_TIMEOUT} (default "5s")
88+
-prometheusShutdownTimeout string
89+
[prometheus] Shutdown Timeout {API_PROMETHEUS_SHUTDOWN_TIMEOUT} (default "5s")
90+
-prometheusWriteTimeout string
91+
[prometheus] Write Timeout {API_PROMETHEUS_WRITE_TIMEOUT} (default "10s")
7892
-readTimeout string
79-
[http] Read Timeout {API_READ_TIMEOUT} (default "5s")
93+
[server] Read Timeout {API_READ_TIMEOUT} (default "5s")
8094
-shutdownTimeout string
81-
[http] Shutdown Timeout {API_SHUTDOWN_TIMEOUT} (default "10s")
95+
[server] Shutdown Timeout {API_SHUTDOWN_TIMEOUT} (default "10s")
8296
-url string
8397
[alcotest] URL to check {API_URL}
8498
-userAgent string
8599
[alcotest] User-Agent for check {API_USER_AGENT} (default "Alcotest")
86100
-writeTimeout string
87-
[http] Write Timeout {API_WRITE_TIMEOUT} (default "10s")
101+
[server] Write Timeout {API_WRITE_TIMEOUT} (default "10s")
88102
```

cmd/goweb/api.go

+24-9
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ import (
99
"github.com/ViBiOh/goweb/pkg/delay"
1010
"github.com/ViBiOh/goweb/pkg/dump"
1111
"github.com/ViBiOh/goweb/pkg/hello"
12-
"github.com/ViBiOh/httputils/v3/pkg/alcotest"
13-
"github.com/ViBiOh/httputils/v3/pkg/cors"
14-
"github.com/ViBiOh/httputils/v3/pkg/httputils"
15-
"github.com/ViBiOh/httputils/v3/pkg/logger"
16-
"github.com/ViBiOh/httputils/v3/pkg/owasp"
17-
"github.com/ViBiOh/httputils/v3/pkg/prometheus"
12+
"github.com/ViBiOh/httputils/v4/pkg/alcotest"
13+
"github.com/ViBiOh/httputils/v4/pkg/cors"
14+
"github.com/ViBiOh/httputils/v4/pkg/flags"
15+
"github.com/ViBiOh/httputils/v4/pkg/health"
16+
"github.com/ViBiOh/httputils/v4/pkg/httputils"
17+
"github.com/ViBiOh/httputils/v4/pkg/logger"
18+
"github.com/ViBiOh/httputils/v4/pkg/owasp"
19+
"github.com/ViBiOh/httputils/v4/pkg/prometheus"
20+
"github.com/ViBiOh/httputils/v4/pkg/server"
1821
)
1922

2023
const (
@@ -26,7 +29,10 @@ const (
2629
func main() {
2730
fs := flag.NewFlagSet("api", flag.ExitOnError)
2831

29-
serverConfig := httputils.Flags(fs, "")
32+
appServerConfig := server.Flags(fs, "")
33+
promServerConfig := server.Flags(fs, "prometheus", flags.NewOverride("Port", 9090), flags.NewOverride("IdleTimeout", "10s"), flags.NewOverride("ShutdownTimeout", "5s"))
34+
healthConfig := health.Flags(fs, "")
35+
3036
alcotestConfig := alcotest.Flags(fs, "")
3137
loggerConfig := logger.Flags(fs, "logger")
3238
prometheusConfig := prometheus.Flags(fs, "prometheus")
@@ -41,11 +47,16 @@ func main() {
4147
logger.Global(logger.New(loggerConfig))
4248
defer logger.Close()
4349

50+
appServer := server.New(appServerConfig)
51+
promServer := server.New(promServerConfig)
52+
prometheusApp := prometheus.New(prometheusConfig)
53+
healthApp := health.New(healthConfig)
54+
4455
helloHandler := http.StripPrefix(helloPath, hello.Handler(helloConfig))
4556
dumpHandler := http.StripPrefix(dumpPath, dump.Handler())
4657
delayHandler := http.StripPrefix(delayPath, delay.Handler())
4758

48-
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
59+
appHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
4960
if strings.HasPrefix(r.URL.Path, helloPath) {
5061
helloHandler.ServeHTTP(w, r)
5162
return
@@ -62,5 +73,9 @@ func main() {
6273
w.WriteHeader(http.StatusNotFound)
6374
})
6475

65-
httputils.New(serverConfig).ListenAndServe(handler, nil, prometheus.New(prometheusConfig).Middleware, owasp.New(owaspConfig).Middleware, cors.New(corsConfig).Middleware)
76+
go promServer.Start("prometheus", healthApp.End(), prometheusApp.Handler())
77+
go appServer.Start("http", healthApp.End(), httputils.Handler(appHandler, healthApp, prometheusApp.Middleware, owasp.New(owaspConfig).Middleware, cors.New(corsConfig).Middleware))
78+
79+
healthApp.WaitForTermination(appServer.Done())
80+
server.GracefulWait(appServer.Done(), promServer.Done())
6681
}

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module github.com/ViBiOh/goweb
22

33
go 1.16
44

5-
require github.com/ViBiOh/httputils/v3 v3.37.2
5+
require github.com/ViBiOh/httputils/v4 v4.0.0

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q
55
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
66
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
77
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
8-
github.com/ViBiOh/httputils/v3 v3.37.2 h1:b3Hm7+PbyBAIitdT0vEvATjZj8lIZ2+0tC8Ecfgd+MI=
9-
github.com/ViBiOh/httputils/v3 v3.37.2/go.mod h1:PocQEM67sTVg51k0kYtoSA3JrwZmEVo5aIBqto/JKek=
8+
github.com/ViBiOh/httputils/v4 v4.0.0 h1:FW7YanNVCcDaKCQ7UAramPv2ovuW2OZndYs8ftHEFb8=
9+
github.com/ViBiOh/httputils/v4 v4.0.0/go.mod h1:+mwW3YVDPI9y1Fx1ZXbehJPqWDFtlDLsNL5otGeBSBw=
1010
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
1111
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
1212
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
@@ -263,8 +263,8 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
263263
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
264264
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
265265
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
266-
github.com/tdewolff/minify/v2 v2.9.12/go.mod h1:yuntVVAFuGyi9VmiRoUqAYEQnFCGO929ytj2ITMZuB8=
267-
github.com/tdewolff/parse/v2 v2.5.9/go.mod h1:WzaJpRSbwq++EIQHYIRTpbYKNA3gn9it1Ik++q4zyho=
266+
github.com/tdewolff/minify/v2 v2.9.13/go.mod h1:faNOp+awAoo+fhFHD+NAkBOaXBAvJI2X2SDERGKnARo=
267+
github.com/tdewolff/parse/v2 v2.5.10/go.mod h1:WzaJpRSbwq++EIQHYIRTpbYKNA3gn9it1Ik++q4zyho=
268268
github.com/tdewolff/test v1.0.6/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
269269
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
270270
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=

infra/config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ spec:
88
chart:
99
spec:
1010
chart: app
11-
version: "0.0.43"
11+
version: "0.0.44"
1212
sourceRef:
1313
kind: HelmRepository
1414
name: vibioh
@@ -23,4 +23,4 @@ spec:
2323
ingress:
2424
enabled: true
2525
hosts:
26-
- api.vibioh.fr
26+
- api.vibioh.fr

pkg/dump/dump.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import (
66
"net/http"
77
"strings"
88

9-
"github.com/ViBiOh/httputils/v3/pkg/httperror"
10-
"github.com/ViBiOh/httputils/v3/pkg/logger"
11-
"github.com/ViBiOh/httputils/v3/pkg/request"
9+
"github.com/ViBiOh/httputils/v4/pkg/httperror"
10+
"github.com/ViBiOh/httputils/v4/pkg/logger"
11+
"github.com/ViBiOh/httputils/v4/pkg/request"
1212
)
1313

1414
// Handler for dump request. Should be use with net/http

pkg/hello/hello.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
88
"strings"
99
"time"
1010

11-
"github.com/ViBiOh/httputils/v3/pkg/flags"
12-
"github.com/ViBiOh/httputils/v3/pkg/httpjson"
13-
"github.com/ViBiOh/httputils/v3/pkg/logger"
11+
"github.com/ViBiOh/httputils/v4/pkg/flags"
12+
"github.com/ViBiOh/httputils/v4/pkg/httpjson"
13+
"github.com/ViBiOh/httputils/v4/pkg/logger"
1414
)
1515

1616
// Hello represents the outputted welcome message

0 commit comments

Comments
 (0)