Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions agent/app/api/v2/website.go
Original file line number Diff line number Diff line change
Expand Up @@ -1223,3 +1223,23 @@
}
helper.Success(c)
}

// @Tags Website
// @Summary Update Stream Config
// @Accept json
// @Param request body request.StreamUpdate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /websites/stream/update [post]
func (b *BaseApi) UpdateStreamConfig(c *gin.Context) {
var req request.StreamUpdate
if err := helper.CheckBindAndValidate(&req, c); err != nil {

Check warning on line 1237 in agent/app/api/v2/website.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this unnecessary variable declaration and use the expression directly in the condition.

See more on https://sonarcloud.io/project/issues?id=1Panel-dev_1Panel&issues=AZsMe2FKQPQEalRtPaX3&open=AZsMe2FKQPQEalRtPaX3&pullRequest=11302
return
}
if err := websiteService.UpdateStream(req); err != nil {
helper.InternalServer(c, err)
return
}
helper.Success(c)
}
15 changes: 15 additions & 0 deletions agent/app/dto/request/website.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ type WebsiteCreate struct {
FtpConfig
DataBaseConfig
SSLConfig
StreamConfig
}

type StreamConfig struct {
StreamPorts string `json:"streamPorts" validate:"required"`
Name string `json:"name"`
Algorithm string `json:"algorithm"`

Servers []dto.NginxUpstreamServer `json:"servers"`
}

type StreamUpdate struct {
WebsiteID uint `json:"websiteID" validate:"required"`

StreamConfig
}

type WebsiteOptionReq struct {
Expand Down
4 changes: 4 additions & 0 deletions agent/app/dto/response/website.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package response
import (
"time"

"github.com/1Panel-dev/1Panel/agent/app/dto"
"github.com/1Panel-dev/1Panel/agent/app/model"
)

Expand All @@ -16,6 +17,9 @@ type WebsiteDTO struct {
RuntimeType string `json:"runtimeType"`
SiteDir string `json:"siteDir"`
OpenBaseDir bool `json:"openBaseDir"`
Algorithm string `json:"algorithm"`

Servers []dto.NginxUpstreamServer `json:"servers"`
}

type WebsiteRes struct {
Expand Down
2 changes: 2 additions & 0 deletions agent/app/model/website.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ type Website struct {

Favorite bool `json:"favorite"`

StreamPorts string `json:"streamPorts"`

Domains []WebsiteDomain `json:"domains" gorm:"-:migration"`
WebsiteSSL WebsiteSSL `json:"webSiteSSL" gorm:"-:migration"`
}
Expand Down
2 changes: 1 addition & 1 deletion agent/app/service/nginx_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func getNginxFull(website *model.Website) (dto.NginxFull, error) {
if website != nil {
nginxFull.Website = *website
var siteNginxConfig dto.NginxConfig
siteConfigPath := GetSitePath(*website, SiteConf)
siteConfigPath := GetWebsiteConfigPath(*website)
siteNginxConfig.FilePath = siteConfigPath
siteNginxContent, err := os.ReadFile(siteConfigPath)
if err != nil {
Expand Down
Loading
Loading