Files
status/router/controller/ping/controller.go
ostiwe fc8b723114 refactor: Fix linter errors by auto-apply
- Apply automated linter fixes
- Manually reformat fields in model/service.go
- Resolve code complexity issues
2025-11-04 19:59:17 +03:00

55 lines
1.1 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/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
}