-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (34 loc) · 860 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"contacts/controllers"
"contacts/models"
"github.com/astaxie/beego"
"github.com/astaxie/beego/context"
)
/*
var staticHandler http.Handler
func init() {
dir := path.Dir(os.Args[0])
// fmt.Println("dir:", http.Dir(dir))
staticHandler = http.FileServer(http.Dir(dir))
}
// 静态文件处理
func StaticServer(w http.ResponseWriter, req *http.Request) {
fmt.Println("path:" + req.URL.Path)
if req.URL.Path != "/down/" {
staticHandler.ServeHTTP(w, req)
return
}
io.WriteString(w, "hello, world!\n")
}
*/
func main() {
beego.Get("/download", func(ctx *context.Context) {
buffer := models.WriteToVCF()
ctx.Output.Body(buffer.Bytes())
// StaticServer(ctx.ResponseWriter, ctx.Request)
})
// beego.Handler("/download", http.FileServer(http.Dir(wd)))
beego.Router("/", &controllers.MainController{})
beego.Run()
}