From a77a085c1f5d5c0f4c3ff8e1f0917f0f2c0c718d Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 23 Nov 2021 15:06:42 +0800
Subject: [PATCH] =?UTF-8?q?=E6=8C=82=E8=BD=BD=E5=89=8D=E7=AB=AF=E6=96=87?=
=?UTF-8?q?=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
log/gin.log | 9 +++++++--
main.go | 5 +++--
routers/web_routers.go | 4 +++-
{views => static}/js/jquery-2.1.4.min.js | 0
views/home/index.html | 2 +-
views/home/index.tpl | 4 ++--
6 files changed, 16 insertions(+), 8 deletions(-)
rename {views => static}/js/jquery-2.1.4.min.js (100%)
diff --git a/log/gin.log b/log/gin.log
index 0ece5f2..de7bd8c 100644
--- a/log/gin.log
+++ b/log/gin.log
@@ -4,12 +4,13 @@
- using env: export GIN_MODE=release
- using code: gin.SetMode(gin.ReleaseMode)
-[GIN-debug] Loaded HTML Templates (4):
- - jquery-2.1.4.min.js
+[GIN-debug] Loaded HTML Templates (3):
-
- index.html
- index.tpl
+[GIN-debug] GET /static/*filepath --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (3 handlers)
+[GIN-debug] HEAD /static/*filepath --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (3 handlers)
[GIN-debug] GET /user/list --> gowebsocket/controllers/user.List (3 handlers)
[GIN-debug] GET /user/online --> gowebsocket/controllers/user.Online (3 handlers)
[GIN-debug] POST /user/sendMessage --> gowebsocket/controllers/user.SendMessage (3 handlers)
@@ -18,3 +19,7 @@
[GIN-debug] GET /home/index --> gowebsocket/controllers/home.Index (3 handlers)
[GIN-debug] GET /rtc/get_token --> gowebsocket/controllers/rtc.GetToken (3 handlers)
[GIN-debug] GET /docker/run --> gowebsocket/controllers/docker.Run (3 handlers)
+[GIN] 2021/11/23 - 15:06:15 | 404 | 2.762µs | 127.0.0.1 | GET "/"
+[GIN] 2021/11/23 - 15:06:21 | 200 | 1.775252ms | 127.0.0.1 | GET "/home/index"
+[GIN] 2021/11/23 - 15:06:21 | 200 | 12.021807ms | 127.0.0.1 | GET "/static/js/jquery-2.1.4.min.js"
+[GIN] 2021/11/23 - 15:06:22 | 200 | 5.363419ms | 127.0.0.1 | GET "/user/list?appId=101"
diff --git a/main.go b/main.go
index a7edd04..5c88acb 100644
--- a/main.go
+++ b/main.go
@@ -9,8 +9,6 @@ package main
import (
"fmt"
- "github.com/gin-gonic/gin"
- "github.com/spf13/viper"
"gowebsocket/lib/redislib"
"gowebsocket/routers"
"gowebsocket/servers/grpcserver"
@@ -21,6 +19,9 @@ import (
"os"
"os/exec"
"time"
+
+ "github.com/gin-gonic/gin"
+ "github.com/spf13/viper"
)
func main() {
diff --git a/routers/web_routers.go b/routers/web_routers.go
index f893cb8..c70f2b6 100644
--- a/routers/web_routers.go
+++ b/routers/web_routers.go
@@ -13,13 +13,15 @@ import (
"gowebsocket/controllers/rtc"
"gowebsocket/controllers/systems"
"gowebsocket/controllers/user"
+ "net/http"
"github.com/gin-gonic/gin"
)
func Init(router *gin.Engine) {
router.LoadHTMLGlob("views/**/*")
-
+ // 静态文件
+ router.StaticFS("/static", http.Dir("static/"))
// 用户组
userRouter := router.Group("/user")
{
diff --git a/views/js/jquery-2.1.4.min.js b/static/js/jquery-2.1.4.min.js
similarity index 100%
rename from views/js/jquery-2.1.4.min.js
rename to static/js/jquery-2.1.4.min.js
diff --git a/views/home/index.html b/views/home/index.html
index 5bd2a8a..b0780f9 100644
--- a/views/home/index.html
+++ b/views/home/index.html
@@ -252,7 +252,7 @@
-
+
+