gpt4 book ai didi

go - 如何在 Gin 中提供静态文件

转载 作者:数据小太阳 更新时间:2023-10-29 03:20:44 27 4
gpt4 key购买 nike

<分区>

按照教程我尝试将前端(React)连接到后端API(Gin),但是static.Serve不起作用,错误提示如下:

cannot use static.Serve("/", static.LocalFile("./views", true)) (type "github.com/gin-gonic/gin".HandlerFunc) as type "github.com/supebirdgz/amgmt/vendor/github.com/gin-gonic/gin".HandlerFunc in argument to router.Use

来源:

import (
"github.com/gin-gonic/gin"
"github.com/gin-gonic/contrib/static"
)

func main() {
router := gin.Default()
router.Use(static.Serve("/", static.LocalFile("./frontend", true)))
router.Run()
}

Gin 有更新吗?我尝试用其他的静态包替换,还是一样。

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com