mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-25 11:10:29 +08:00
阶段性提交
This commit is contained in:
@@ -2,22 +2,33 @@ package ui
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/conds/condutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||
"github.com/iwind/TeaGo/Tea"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/files"
|
||||
"github.com/iwind/TeaGo/logs"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type ComponentsAction actions.Action
|
||||
|
||||
var componentsData = []byte{}
|
||||
var componentsDataSum string
|
||||
|
||||
func (this *ComponentsAction) RunGet(params struct{}) {
|
||||
this.AddHeader("Content-Type", "text/javascript; charset=utf-8")
|
||||
|
||||
// etag
|
||||
var requestETag = this.Header("If-None-Match")
|
||||
if len(requestETag) > 0 && requestETag == "\""+componentsDataSum+"\"" {
|
||||
this.ResponseWriter.WriteHeader(http.StatusNotModified)
|
||||
return
|
||||
}
|
||||
|
||||
if !Tea.IsTesting() && len(componentsData) > 0 {
|
||||
this.AddHeader("Last-Modified", "Fri, 06 Sep 2019 08:29:50 GMT")
|
||||
this.Write(componentsData)
|
||||
@@ -81,5 +92,12 @@ func (this *ComponentsAction) RunGet(params struct{}) {
|
||||
}
|
||||
|
||||
componentsData = buffer.Bytes()
|
||||
|
||||
// ETag
|
||||
var h = md5.New()
|
||||
h.Write(buffer.Bytes())
|
||||
componentsDataSum = fmt.Sprintf("%x", h.Sum(nil))
|
||||
this.AddHeader("ETag", "\""+componentsDataSum+"\"")
|
||||
|
||||
this.Write(componentsData)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user