File tree Expand file tree Collapse file tree 2 files changed +13
-8
lines changed
Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,11 @@ const (
2020 ErrResourceNotFound = "resource not found"
2121)
2222
23+ type HealthCheckResponse struct {
24+ Tag string `json:"tag"`
25+ Commit string `json:"commit"`
26+ }
27+
2328// @title Gilfoyle server
2429// @description Cloud-native media hosting & streaming server for businesses.
2530// @version v1
@@ -56,12 +61,12 @@ func RegisterRoutes(r *gin.Engine) *gin.Engine {
5661// @Summary Check service status
5762// @Description Check for the health of the service
5863// @Produce json
59- // @Success 200 {object} httputils.DataResponse{data=map[string]string }
64+ // @Success 200 {object} httputils.DataResponse{data=HealthCheckResponse }
6065// @Router /health [get]
6166func healthCheckHandler (ctx * gin.Context ) {
62- httputils .NewData (ctx , http .StatusOK , map [ string ] string {
63- "tag" : config .Version ,
64- "commit" : config .Commit ,
67+ httputils .NewData (ctx , http .StatusOK , HealthCheckResponse {
68+ Tag : config .Version ,
69+ Commit : config .Commit ,
6570 })
6671}
6772
Original file line number Diff line number Diff line change @@ -34,13 +34,13 @@ func TestApi(t *testing.T) {
3434 assert .NoError (err )
3535
3636 var body struct {
37- Code int `json:"code"`
38- Data map [ string ] string `json:"data,omitempty"`
37+ Code int `json:"code"`
38+ Data HealthCheckResponse `json:"data,omitempty"`
3939 }
4040 _ = json .NewDecoder (res .Body ).Decode (& body )
4141
4242 assert .Equal (200 , body .Code )
43- assert .Equal (config .Version , body .Data [ "tag" ] )
44- assert .Equal (config .Commit , body .Data [ "commit" ] )
43+ assert .Equal (config .Version , body .Data . Tag )
44+ assert .Equal (config .Commit , body .Data . Commit )
4545 })
4646}
You can’t perform that action at this time.
0 commit comments