mirror of
https://github.com/quarkcloudio/quark-go.git
synced 2025-10-09 09:50:12 +08:00
chore: 新增Static方法
This commit is contained in:
@@ -42,10 +42,13 @@ func main() {
|
||||
// 实例化对象
|
||||
b := builder.New(config)
|
||||
|
||||
// 静态文件
|
||||
b.Static("/", "./website")
|
||||
|
||||
// 自动构建数据库、拉取静态文件
|
||||
b.Use(install.Handle)
|
||||
|
||||
// 使用后台中间件
|
||||
// 后台中间件
|
||||
b.Use(middleware.Handle)
|
||||
|
||||
// 响应Get请求
|
||||
|
@@ -23,19 +23,24 @@ func main() {
|
||||
},
|
||||
}
|
||||
|
||||
// 创建对象
|
||||
// 实例化对象
|
||||
b := builder.New(config)
|
||||
|
||||
// 初始化安装
|
||||
// 静态文件
|
||||
b.Static("/", "./website")
|
||||
|
||||
// 自动构建数据库、拉取静态文件
|
||||
b.Use(install.Handle)
|
||||
|
||||
// 中间件
|
||||
// 后台中间件
|
||||
b.Use(middleware.Handle)
|
||||
|
||||
// 响应Get请求
|
||||
b.GET("/", func(ctx *builder.Context) error {
|
||||
ctx.Write([]byte("hello world!"))
|
||||
return nil
|
||||
})
|
||||
|
||||
// 启动服务
|
||||
b.Run(":3000")
|
||||
}
|
||||
|
@@ -482,12 +482,14 @@ func (p *Engine) Any(path string, handle Handle) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// tatic registers a new route with path prefix to serve static files from the provided root directory.
|
||||
func (p *Engine) Static(pathPrefix string, fsRoot string) {
|
||||
p.Echo.Static(pathPrefix, fsRoot)
|
||||
}
|
||||
|
||||
// Run Server
|
||||
func (p *Engine) Run(addr string) {
|
||||
|
||||
// 静态文件目录
|
||||
p.Echo.Static("/", "./website")
|
||||
|
||||
// 处理模版上的路由映射关系
|
||||
p.routeMappingParser()
|
||||
|
||||
|
Reference in New Issue
Block a user