2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-05 04:30:13 +08:00
Files
panel/app/http/controllers/swagger_controller.go
2023-12-14 01:27:34 +08:00

54 lines
1.1 KiB
Go

package controllers
import (
"github.com/gofiber/swagger"
"github.com/goravel/fiber"
"github.com/goravel/framework/contracts/http"
"github.com/goravel/framework/facades"
_ "panel/docs"
)
type SwaggerController struct {
// Dependent services
}
// Config stores fiberSwagger configuration variables.
type Config struct {
URL string
InstanceName string
DocExpansion string
DomID string
DeepLinking bool
PersistAuthorization bool
}
func NewSwaggerController() *SwaggerController {
return &SwaggerController{
// Inject services
}
}
// Index
//
// @Summary Swagger UI
// @Description Swagger UI
// @Tags Swagger
// @Success 200
// @Failure 500
// @Router /swagger [get]
func (r *SwaggerController) Index(ctx http.Context) http.Response {
if !facades.Config().GetBool("app.debug") {
return Error(ctx, http.StatusNotFound, http.StatusText(http.StatusNotFound))
}
err := swagger.New(swagger.Config{
Title: "耗子面板 Swagger",
})(ctx.(*fiber.Context).Instance())
if err != nil {
return Error(ctx, http.StatusNotFound, err.Error())
}
return nil
}