Skip to content

Commit

Permalink
feat: 更新openresty插件文档
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed Jun 17, 2024
1 parent 0be04e1 commit 8bcc0c0
Show file tree
Hide file tree
Showing 4 changed files with 375 additions and 5 deletions.
46 changes: 41 additions & 5 deletions app/http/controllers/plugins/openresty_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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, "")
Expand All @@ -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)
Expand All @@ -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")
Expand Down
129 changes: 129 additions & 0 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
129 changes: 129 additions & 0 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Loading

0 comments on commit 8bcc0c0

Please sign in to comment.