Skip to content

Commit

Permalink
Merge pull request #262 from checkr/zz/fix-health-check-endpoint
Browse files Browse the repository at this point in the history
Fix health check endpoint
  • Loading branch information
zhouzhuojie authored May 24, 2019
2 parents e701af9 + 484680f commit 1293e27
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ serve_docs:
################################

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

checks:
Expand Down
11 changes: 9 additions & 2 deletions docs/api_docs/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ info:
Flagr is a feature flagging, A/B testing and dynamic configuration
microservice. The base path for all the APIs is "/api/v1".
title: Flagr
version: 1.1.0
version: 1.1.2
tags:
- name: flag
description: Everything about the flag
Expand Down Expand Up @@ -759,7 +759,9 @@ paths:
description: Check if Flagr is healthy
responses:
'200':
description: OK
description: status of health check
schema:
$ref: '#/definitions/health'
default:
description: generic error response
schema:
Expand Down Expand Up @@ -1218,6 +1220,11 @@ definitions:
type: array
items:
$ref: '#/definitions/evalResult'
health:
type: object
properties:
status:
type: string
error:
type: object
required:
Expand Down
2 changes: 1 addition & 1 deletion docs/home.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Install Dependencies.

- Go
- Make (for Makefile)
- Yarn (for building UI)
- Yarn and NPM (for building UI)
- SQLite3 (for testing)

Build from source.
Expand Down
1 change: 1 addition & 0 deletions integration_tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ step_1_test_health()

shakedown GET $flagr_url/health
status 200
content_type 'application/json'
}

step_2_test_crud_flag()
Expand Down
5 changes: 4 additions & 1 deletion pkg/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package handler
import (
"github.com/checkr/flagr/pkg/config"
"github.com/checkr/flagr/pkg/entity"
"github.com/checkr/flagr/swagger_gen/models"
"github.com/checkr/flagr/swagger_gen/restapi/operations"
"github.com/checkr/flagr/swagger_gen/restapi/operations/constraint"
"github.com/checkr/flagr/swagger_gen/restapi/operations/distribution"
Expand Down Expand Up @@ -83,7 +84,9 @@ func setupEvaluation(api *operations.FlagrAPI) {

func setupHealth(api *operations.FlagrAPI) {
api.HealthGetHealthHandler = health.GetHealthHandlerFunc(
func(health.GetHealthParams) middleware.Responder { return &health.GetHealthOK{} },
func(health.GetHealthParams) middleware.Responder {
return health.NewGetHealthOK().WithPayload(&models.Health{Status: "OK"})
},
)
}

Expand Down
4 changes: 3 additions & 1 deletion swagger/health.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ get:
description: Check if Flagr is healthy
responses:
200:
description: OK
description: status of health check
schema:
$ref: "#/definitions/health"
default:
description: generic error response
schema:
Expand Down
9 changes: 8 additions & 1 deletion swagger/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ info:
Flagr is a feature flagging, A/B testing and dynamic configuration microservice.
The base path for all the APIs is "/api/v1".
title: Flagr
version: 1.1.0
version: 1.1.2
tags:
- name: flag
description: Everything about the flag
Expand Down Expand Up @@ -507,6 +507,13 @@ definitions:
items:
$ref: "#/definitions/evalResult"

# Health check
health:
type: object
properties:
status:
type: string

# Default Error
error:
type: object
Expand Down
43 changes: 43 additions & 0 deletions swagger_gen/models/health.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion swagger_gen/restapi/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 26 additions & 4 deletions swagger_gen/restapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 23 additions & 3 deletions swagger_gen/restapi/operations/health/get_health_responses.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1293e27

Please sign in to comment.