From 189a0cbb02ed481d4967bc924e4bba032cc73e93 Mon Sep 17 00:00:00 2001 From: Howl Date: Sun, 10 Apr 2016 23:14:44 +0200 Subject: [PATCH] Add GET /api/status for Ripple's status page. --- app/internals/status.go | 17 +++++++++++++++++ app/start.go | 3 +++ 2 files changed, 20 insertions(+) create mode 100644 app/internals/status.go diff --git a/app/internals/status.go b/app/internals/status.go new file mode 100644 index 0000000..a5d4a94 --- /dev/null +++ b/app/internals/status.go @@ -0,0 +1,17 @@ +// Package internals has methods that suit none of the API packages. +package internals + +import ( + "github.com/gin-gonic/gin" +) + +type statusResponse struct { + Response int `json:"response"` +} + +// Status is used for checking the API is up by the ripple website, on the status page. +func Status(c *gin.Context) { + c.JSON(200, statusResponse{ + Response: 1, + }) +} diff --git a/app/start.go b/app/start.go index e6d038c..43f28c5 100644 --- a/app/start.go +++ b/app/start.go @@ -5,6 +5,7 @@ import ( "github.com/gin-gonic/contrib/gzip" "github.com/gin-gonic/gin" + "github.com/osuripple/api/app/internals" "github.com/osuripple/api/app/v1" "github.com/osuripple/api/common" ) @@ -54,6 +55,8 @@ func Start(conf common.Conf, db *sql.DB) *gin.Engine { gv1.GET("/meta/up_since", Method(v1.MetaUpSinceGET, db, common.PrivilegeAPIMeta)) gv1.GET("/meta/update", Method(v1.MetaUpdateGET, db, common.PrivilegeAPIMeta)) } + + api.GET("/status", internals.Status) } r.NoRoute(v1.Handle404)