Add server stats endpoint
This commit is contained in:
parent
19c277661b
commit
5f6dc903f5
2 changed files with 30 additions and 0 deletions
25
server/info.go
Normal file
25
server/info.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
// Copyright © 2016 Abcum Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package server
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo"
|
||||
)
|
||||
|
||||
func info(c *echo.Context) error {
|
||||
|
||||
return c.JSON(200, stat.Data())
|
||||
|
||||
}
|
|
@ -22,8 +22,11 @@ import (
|
|||
"github.com/abcum/surreal/server/api"
|
||||
"github.com/labstack/echo"
|
||||
"github.com/labstack/echo/middleware"
|
||||
"github.com/thoas/stats"
|
||||
)
|
||||
|
||||
var stat *stats.Stats
|
||||
|
||||
// Setup sets up the server for remote connections
|
||||
func Setup(ctx cnf.Context) (e error) {
|
||||
|
||||
|
@ -43,6 +46,7 @@ func Setup(ctx cnf.Context) (e error) {
|
|||
r.AutoIndex(false)
|
||||
r.SetHTTPErrorHandler(errors)
|
||||
|
||||
r.Use(stat.Handler)
|
||||
r.Use(middleware.Gzip())
|
||||
r.Use(middleware.Logger())
|
||||
r.Use(middleware.Recover())
|
||||
|
@ -69,6 +73,7 @@ func Setup(ctx cnf.Context) (e error) {
|
|||
s.AutoIndex(false)
|
||||
s.SetHTTPErrorHandler(errors)
|
||||
|
||||
s.Use(stat.Handler)
|
||||
s.Use(middleware.Gzip())
|
||||
s.Use(middleware.Logger())
|
||||
s.Use(middleware.Recover())
|
||||
|
|
Loading…
Reference in a new issue