File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 1- ci : golang-ci
1+ ci : go-tests go-cover golang-ci
2+
3+ go-tests : src/* go.mod go.sum
4+ go test -v ./...
5+
6+ go-cover : src/* go.mod go.sum
7+ go test -coverprofile=coverage.out ./...
28
39golang-ci : src/* go.mod go.sum
410 docker run --rm -t \
Original file line number Diff line number Diff line change @@ -2,12 +2,13 @@ package main
22
33import (
44 "fmt"
5+ "net/http"
6+
57 "github.com/gin-contrib/logger"
68 "github.com/gin-contrib/requestid"
79 "github.com/gin-gonic/gin"
810 "github.com/rs/zerolog"
911 "github.com/spf13/cobra"
10- "net/http"
1112)
1213
1314func main () {
@@ -34,12 +35,18 @@ func main() {
3435 r .Use (requestid .New ())
3536 r .Use (logger .SetLogger (l ))
3637
37- r .GET ("/" , func (c * gin.Context ) {
38+ // Health check endpoint
39+ r .GET ("/health" , func (c * gin.Context ) {
40+ c .String (http .StatusOK , "OK" )
41+ })
42+
43+ // Check the presence of the header in all requests
44+ r .NoRoute (func (c * gin.Context ) {
3845 value := c .GetHeader (headerName )
3946 if value == expectedValue {
4047 c .String (http .StatusOK , "HTTP header is present with the expected value." )
4148 } else {
42- c .String (http .StatusNotFound , "HTTP header is not present with the expected value." )
49+ c .String (http .StatusForbidden , "HTTP header is not present with the expected value." )
4350 }
4451 })
4552
You can’t perform that action at this time.
0 commit comments