mirror of
https://gitee.com/johng/gf
synced 2026-06-07 10:22:11 +08:00
增加HTTP下载文件示例程序
This commit is contained in:
15
geg/net/ghttp/server/download/download.go
Normal file
15
geg/net/ghttp/server/download/download.go
Normal file
@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"gitee.com/johng/gf/g"
|
||||
"gitee.com/johng/gf/g/net/ghttp"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := g.Server()
|
||||
s.BindHandler("/download", func(r *ghttp.Request){
|
||||
r.Response.ServeFile("text.txt")
|
||||
})
|
||||
s.SetPort(8199)
|
||||
s.Run()
|
||||
}
|
||||
1
geg/net/ghttp/server/download/text.txt
Normal file
1
geg/net/ghttp/server/download/text.txt
Normal file
@ -0,0 +1 @@
|
||||
下载文件内容。
|
||||
Reference in New Issue
Block a user