Skip to content

Commit

Permalink
Merge pull request #140 from checkr/zz/add-health-handler
Browse files Browse the repository at this point in the history
Add health handler
  • Loading branch information
zhouzhuojie authored Jul 6, 2018
2 parents ba42137 + 044b8c6 commit 3e8098c
Show file tree
Hide file tree
Showing 10 changed files with 371 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/api_docs/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,17 @@ paths:
description: generic error response
schema:
$ref: '#/definitions/error'
/health:
get:
tags:
- health
responses:
'200':
description: Flagr is healthy
default:
description: generic error response
schema:
$ref: '#/definitions/error'
definitions:
flag:
type: object
Expand Down
11 changes: 11 additions & 0 deletions pkg/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import (
"github.com/checkr/flagr/swagger_gen/restapi/operations/distribution"
"github.com/checkr/flagr/swagger_gen/restapi/operations/evaluation"
"github.com/checkr/flagr/swagger_gen/restapi/operations/flag"
"github.com/checkr/flagr/swagger_gen/restapi/operations/health"
"github.com/checkr/flagr/swagger_gen/restapi/operations/segment"
"github.com/checkr/flagr/swagger_gen/restapi/operations/variant"
"github.com/go-openapi/runtime/middleware"
)

var getDB = repo.GetDB
Expand All @@ -17,6 +19,7 @@ var getDB = repo.GetDB
func Setup(api *operations.FlagrAPI) {
setupCRUD(api)
setupEvaluation(api)
setupHealth(api)
}

func setupCRUD(api *operations.FlagrAPI) {
Expand Down Expand Up @@ -62,3 +65,11 @@ func setupEvaluation(api *operations.FlagrAPI) {
api.EvaluationPostEvaluationHandler = evaluation.PostEvaluationHandlerFunc(e.PostEvaluation)
api.EvaluationPostEvaluationBatchHandler = evaluation.PostEvaluationBatchHandlerFunc(e.PostEvaluationBatch)
}

func setupHealth(api *operations.FlagrAPI) {
api.HealthGetHealthHandler = health.GetHealthHandlerFunc(
func(health.GetHealthParams) middleware.Responder {
return &health.GetHealthOK{}
},
)
}
10 changes: 10 additions & 0 deletions swagger/health.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
get:
tags:
- health
responses:
200:
description: Flagr is healthy
default:
description: generic error response
schema:
$ref: "#/definitions/error"
2 changes: 2 additions & 0 deletions swagger/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ paths:
$ref: ./evaluation.yaml
/evaluation/batch:
$ref: ./evaluation_batch.yaml
/health:
$ref: ./health.yaml
definitions:
# Flag
flag:
Expand Down
36 changes: 36 additions & 0 deletions swagger_gen/restapi/embedded_spec.go

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

15 changes: 15 additions & 0 deletions swagger_gen/restapi/operations/flagr_api.go

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

58 changes: 58 additions & 0 deletions swagger_gen/restapi/operations/health/get_health.go

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

45 changes: 45 additions & 0 deletions swagger_gen/restapi/operations/health/get_health_parameters.go

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

96 changes: 96 additions & 0 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.

Loading

0 comments on commit 3e8098c

Please sign in to comment.