diff --git a/app/http/controllers/plugins/openresty_controller.go b/app/http/controllers/plugins/openresty_controller.go index 7d05a9d3..2b7cd913 100644 --- a/app/http/controllers/plugins/openresty_controller.go +++ b/app/http/controllers/plugins/openresty_controller.go @@ -20,7 +20,14 @@ func NewOpenrestyController() *OpenRestyController { return &OpenRestyController{} } -// GetConfig 获取配置 +// GetConfig +// +// @Summary 获取配置 +// @Tags 插件-OpenResty +// @Produce json +// @Security BearerToken +// @Success 200 {object} controllers.SuccessResponse +// @Router /plugins/openresty/config [get] func (r *OpenRestyController) GetConfig(ctx http.Context) http.Response { config, err := tools.Read("/www/server/openresty/conf/nginx.conf") if err != nil { @@ -30,7 +37,15 @@ func (r *OpenRestyController) GetConfig(ctx http.Context) http.Response { return controllers.Success(ctx, config) } -// SaveConfig 保存配置 +// SaveConfig +// +// @Summary 保存配置 +// @Tags 插件-OpenResty +// @Produce json +// @Security BearerToken +// @Param config body string true "配置" +// @Success 200 {object} controllers.SuccessResponse +// @Router /plugins/openresty/config [post] func (r *OpenRestyController) SaveConfig(ctx http.Context) http.Response { config := ctx.Request().Input("config") if len(config) == 0 { @@ -48,7 +63,14 @@ func (r *OpenRestyController) SaveConfig(ctx http.Context) http.Response { return controllers.Success(ctx, nil) } -// ErrorLog 获取错误日志 +// ErrorLog +// +// @Summary 获取错误日志 +// @Tags 插件-OpenResty +// @Produce json +// @Security BearerToken +// @Success 200 {object} controllers.SuccessResponse +// @Router /plugins/openresty/errorLog [get] func (r *OpenRestyController) ErrorLog(ctx http.Context) http.Response { if !tools.Exists("/www/wwwlogs/nginx_error.log") { return controllers.Success(ctx, "") @@ -62,7 +84,14 @@ func (r *OpenRestyController) ErrorLog(ctx http.Context) http.Response { return controllers.Success(ctx, out) } -// ClearErrorLog 清空错误日志 +// ClearErrorLog +// +// @Summary 清空错误日志 +// @Tags 插件-OpenResty +// @Produce json +// @Security BearerToken +// @Success 200 {object} controllers.SuccessResponse +// @Router /plugins/openresty/clearErrorLog [post] func (r *OpenRestyController) ClearErrorLog(ctx http.Context) http.Response { if out, err := tools.Exec("echo '' > /www/wwwlogs/openresty_error.log"); err != nil { return controllers.Error(ctx, http.StatusInternalServerError, out) @@ -71,7 +100,14 @@ func (r *OpenRestyController) ClearErrorLog(ctx http.Context) http.Response { return controllers.Success(ctx, nil) } -// Load 获取负载 +// Load +// +// @Summary 获取负载状态 +// @Tags 插件-OpenResty +// @Produce json +// @Security BearerToken +// @Success 200 {object} controllers.SuccessResponse +// @Router /plugins/openresty/load [get] func (r *OpenRestyController) Load(ctx http.Context) http.Response { client := resty.New().SetTimeout(10 * time.Second) resp, err := client.R().Get("http://127.0.0.1/nginx_status") diff --git a/docs/docs.go b/docs/docs.go index fd73af3b..7265c1b7 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -4001,6 +4001,135 @@ const docTemplate = `{ } } }, + "/plugins/openresty/clearErrorLog": { + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "插件-OpenResty" + ], + "summary": "清空错误日志", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/plugins/openresty/config": { + "get": { + "security": [ + { + "BearerToken": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "插件-OpenResty" + ], + "summary": "获取配置", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + }, + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "插件-OpenResty" + ], + "summary": "保存配置", + "parameters": [ + { + "description": "配置", + "name": "config", + "in": "body", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/plugins/openresty/errorLog": { + "get": { + "security": [ + { + "BearerToken": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "插件-OpenResty" + ], + "summary": "获取错误日志", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/plugins/openresty/load": { + "get": { + "security": [ + { + "BearerToken": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "插件-OpenResty" + ], + "summary": "获取负载状态", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, "/plugins/php/{version}/clearErrorLog": { "post": { "security": [ diff --git a/docs/swagger.json b/docs/swagger.json index 91632d61..9f896fc3 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -3994,6 +3994,135 @@ } } }, + "/plugins/openresty/clearErrorLog": { + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "插件-OpenResty" + ], + "summary": "清空错误日志", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/plugins/openresty/config": { + "get": { + "security": [ + { + "BearerToken": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "插件-OpenResty" + ], + "summary": "获取配置", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + }, + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "插件-OpenResty" + ], + "summary": "保存配置", + "parameters": [ + { + "description": "配置", + "name": "config", + "in": "body", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/plugins/openresty/errorLog": { + "get": { + "security": [ + { + "BearerToken": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "插件-OpenResty" + ], + "summary": "获取错误日志", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/plugins/openresty/load": { + "get": { + "security": [ + { + "BearerToken": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "插件-OpenResty" + ], + "summary": "获取负载状态", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, "/plugins/php/{version}/clearErrorLog": { "post": { "security": [ diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 82eb4892..4475bd6c 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -3096,6 +3096,82 @@ paths: summary: 更新配置 tags: - 插件-Gitea + /plugins/openresty/clearErrorLog: + post: + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controllers.SuccessResponse' + security: + - BearerToken: [] + summary: 清空错误日志 + tags: + - 插件-OpenResty + /plugins/openresty/config: + get: + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controllers.SuccessResponse' + security: + - BearerToken: [] + summary: 获取配置 + tags: + - 插件-OpenResty + post: + parameters: + - description: 配置 + in: body + name: config + required: true + schema: + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controllers.SuccessResponse' + security: + - BearerToken: [] + summary: 保存配置 + tags: + - 插件-OpenResty + /plugins/openresty/errorLog: + get: + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controllers.SuccessResponse' + security: + - BearerToken: [] + summary: 获取错误日志 + tags: + - 插件-OpenResty + /plugins/openresty/load: + get: + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controllers.SuccessResponse' + security: + - BearerToken: [] + summary: 获取负载状态 + tags: + - 插件-OpenResty /plugins/php/{version}/clearErrorLog: post: parameters: