mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2026-01-06 23:45:47 +08:00
优化代码
This commit is contained in:
@@ -27,7 +27,6 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials"
|
||||
"gopkg.in/yaml.v3"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
@@ -313,7 +312,7 @@ func (this *APINode) autoUpgrade() error {
|
||||
|
||||
// 执行SQL
|
||||
var config = &dbs.Config{}
|
||||
configData, err := ioutil.ReadFile(Tea.ConfigFile("db.yaml"))
|
||||
configData, err := os.ReadFile(Tea.ConfigFile("db.yaml"))
|
||||
if err != nil {
|
||||
return errors.New("read database config file failed: " + err.Error())
|
||||
}
|
||||
@@ -785,6 +784,6 @@ func (this *APINode) dbIssueSuggestion(errString string) string {
|
||||
func (this *APINode) saveIssues() {
|
||||
issuesJSON, err := json.Marshal(this.issues)
|
||||
if err == nil {
|
||||
_ = ioutil.WriteFile(this.issuesFile, issuesJSON, 0666)
|
||||
_ = os.WriteFile(this.issuesFile, issuesJSON, 0666)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/rpc/services"
|
||||
rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"reflect"
|
||||
@@ -152,7 +152,7 @@ func (this *RestServer) handle(writer http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
|
||||
// TODO 需要防止BODY过大攻击
|
||||
body, err := ioutil.ReadAll(req.Body)
|
||||
body, err := io.ReadAll(req.Body)
|
||||
if err != nil {
|
||||
writer.WriteHeader(http.StatusBadRequest)
|
||||
_, _ = writer.Write([]byte(err.Error()))
|
||||
|
||||
Reference in New Issue
Block a user