Skip to content

Commit 1293e27

Browse files
authored
Merge pull request #262 from checkr/zz/fix-health-check-endpoint
Fix health check endpoint
2 parents e701af9 + 484680f commit 1293e27

File tree

11 files changed

+120
-15
lines changed

11 files changed

+120
-15
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ serve_docs:
5252
################################
5353

5454
api_docs:
55-
@echo "Installing swagger-merger" && yarn global add swagger-merger
55+
@echo "Installing swagger-merger" && npm install swagger-merger -g
5656
@swagger-merger -i $(PWD)/swagger/index.yaml -o $(PWD)/docs/api_docs/bundle.yaml
5757

5858
checks:

docs/api_docs/bundle.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ info:
44
Flagr is a feature flagging, A/B testing and dynamic configuration
55
microservice. The base path for all the APIs is "/api/v1".
66
title: Flagr
7-
version: 1.1.0
7+
version: 1.1.2
88
tags:
99
- name: flag
1010
description: Everything about the flag
@@ -759,7 +759,9 @@ paths:
759759
description: Check if Flagr is healthy
760760
responses:
761761
'200':
762-
description: OK
762+
description: status of health check
763+
schema:
764+
$ref: '#/definitions/health'
763765
default:
764766
description: generic error response
765767
schema:
@@ -1218,6 +1220,11 @@ definitions:
12181220
type: array
12191221
items:
12201222
$ref: '#/definitions/evalResult'
1223+
health:
1224+
type: object
1225+
properties:
1226+
status:
1227+
type: string
12211228
error:
12221229
type: object
12231230
required:

docs/home.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Install Dependencies.
3737

3838
- Go
3939
- Make (for Makefile)
40-
- Yarn (for building UI)
40+
- Yarn and NPM (for building UI)
4141
- SQLite3 (for testing)
4242

4343
Build from source.

integration_tests/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ step_1_test_health()
1212

1313
shakedown GET $flagr_url/health
1414
status 200
15+
content_type 'application/json'
1516
}
1617

1718
step_2_test_crud_flag()

pkg/handler/handler.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package handler
33
import (
44
"github.com/checkr/flagr/pkg/config"
55
"github.com/checkr/flagr/pkg/entity"
6+
"github.com/checkr/flagr/swagger_gen/models"
67
"github.com/checkr/flagr/swagger_gen/restapi/operations"
78
"github.com/checkr/flagr/swagger_gen/restapi/operations/constraint"
89
"github.com/checkr/flagr/swagger_gen/restapi/operations/distribution"
@@ -83,7 +84,9 @@ func setupEvaluation(api *operations.FlagrAPI) {
8384

8485
func setupHealth(api *operations.FlagrAPI) {
8586
api.HealthGetHealthHandler = health.GetHealthHandlerFunc(
86-
func(health.GetHealthParams) middleware.Responder { return &health.GetHealthOK{} },
87+
func(health.GetHealthParams) middleware.Responder {
88+
return health.NewGetHealthOK().WithPayload(&models.Health{Status: "OK"})
89+
},
8790
)
8891
}
8992

swagger/health.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ get:
55
description: Check if Flagr is healthy
66
responses:
77
200:
8-
description: OK
8+
description: status of health check
9+
schema:
10+
$ref: "#/definitions/health"
911
default:
1012
description: generic error response
1113
schema:

swagger/index.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ info:
55
Flagr is a feature flagging, A/B testing and dynamic configuration microservice.
66
The base path for all the APIs is "/api/v1".
77
title: Flagr
8-
version: 1.1.0
8+
version: 1.1.2
99
tags:
1010
- name: flag
1111
description: Everything about the flag
@@ -507,6 +507,13 @@ definitions:
507507
items:
508508
$ref: "#/definitions/evalResult"
509509

510+
# Health check
511+
health:
512+
type: object
513+
properties:
514+
status:
515+
type: string
516+
510517
# Default Error
511518
error:
512519
type: object

swagger_gen/models/health.go

Lines changed: 43 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swagger_gen/restapi/doc.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swagger_gen/restapi/embedded_spec.go

Lines changed: 26 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)