1.4.5.2
This commit is contained in:
38
EdgeUser/internal/web/actions/default/qrcode/index.go
Normal file
38
EdgeUser/internal/web/actions/default/qrcode/index.go
Normal file
@@ -0,0 +1,38 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package qrcode
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeUser/internal/ttlcache"
|
||||
"github.com/TeaOSLab/EdgeUser/internal/web/actions/actionutils"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
Key string
|
||||
}) {
|
||||
var item = ttlcache.DefaultCache.Read(params.Key)
|
||||
if item == nil || item.Value == nil {
|
||||
this.ResponseWriter.WriteHeader(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
data, ok := item.Value.([]byte)
|
||||
if !ok {
|
||||
this.ResponseWriter.WriteHeader(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
this.AddHeader("Content-Type", "image/png")
|
||||
this.AddHeader("Content-Length", types.String(len(data)))
|
||||
_, _ = this.Write(data)
|
||||
}
|
||||
Reference in New Issue
Block a user