63 lines
1.2 KiB
Go
63 lines
1.2 KiB
Go
package ping
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"git.ostiwe.com/ostiwe-com/status/modules/log"
|
|
"git.ostiwe.com/ostiwe-com/status/router/controller"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/go-andiamo/chioas"
|
|
)
|
|
|
|
type Controller struct {
|
|
}
|
|
|
|
func (c *Controller) Method() string {
|
|
return http.MethodGet
|
|
}
|
|
|
|
func (c *Controller) Path() string {
|
|
return "/api/v1/ping"
|
|
}
|
|
|
|
func (*Controller) New() controller.Controller {
|
|
return &Controller{}
|
|
}
|
|
|
|
func (c *Controller) Handler() gin.HandlerFunc {
|
|
return func(ginCtx *gin.Context) {
|
|
_, err := ginCtx.Writer.Write([]byte("pong"))
|
|
if err != nil {
|
|
log.Global.Get(log.SERVER).Error(err)
|
|
return
|
|
}
|
|
}
|
|
}
|
|
|
|
func (c *Controller) Documentate() (*chioas.Paths, *chioas.Components) {
|
|
return &chioas.Paths{
|
|
"/ping": chioas.Path{
|
|
Methods: map[string]chioas.Method{
|
|
http.MethodGet: {
|
|
Handler: c.Handler(),
|
|
Responses: chioas.Responses{
|
|
http.StatusOK: {
|
|
ContentType: "plain/text",
|
|
Schema: chioas.Schema{Type: "string"},
|
|
Examples: chioas.Examples{
|
|
{
|
|
|
|
Name: "200 OK",
|
|
Value: "pong",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
Tag: "service",
|
|
Comment: "Route for check service is alive",
|
|
},
|
|
}, nil
|
|
}
|