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/swaggest/openapi-go" "github.com/swaggest/openapi-go/openapi3" ) 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(r *openapi3.Reflector) openapi.OperationContext { op, err := r.NewOperationContext(c.Method(), c.Path()) if err != nil { return nil } op.SetDescription("Route for check service is alive") op.SetSummary("Server ping") op.AddRespStructure("pong", func(cu *openapi.ContentUnit) { cu.ContentType = "plain/text" cu.HTTPStatus = http.StatusOK }) return op }