forked from devfeel/dotweb
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
41 lines (32 loc) · 872 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
package main
import (
"fmt"
"github.com/devfeel/dotweb"
"github.com/devfeel/dotweb/framework/file"
"strconv"
)
func main() {
//初始化DotServer
app := dotweb.New()
//设置dotserver日志目录
app.SetLogPath(file.GetCurrentDirectory())
app.HttpServer.SetEnabledListDir(false)
//设置路由
InitRoute(app.HttpServer)
//启动 监控服务
//app.SetPProfConfig(true, 8081)
// 开始服务
port := 8080
fmt.Println("dotweb.StartServer => " + strconv.Itoa(port))
err := app.StartServer(port)
fmt.Println("dotweb.StartServer error => ", err)
}
func Index(ctx dotweb.Context) error {
ctx.Response().Header().Set("Content-Type", "text/html; charset=utf-8")
_, err := ctx.WriteString("index")
return err
}
func InitRoute(server *dotweb.HttpServer) {
server.Router().GET("/", Index)
server.Router().ServerFile("/static/*filepath", "d:/gotmp")
}