2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 10:17:17 +08:00

feat: 更新openresty插件文档

This commit is contained in:
耗子
2024-06-18 01:29:44 +08:00
parent 0be04e1859
commit 8bcc0c0c05
4 changed files with 375 additions and 5 deletions

View File

@@ -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")

View File

@@ -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": [

View File

@@ -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": [

View File

@@ -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: