()
| 10 | ) |
| 11 | |
| 12 | func main() { |
| 13 | //初始化DotServer |
| 14 | app := dotweb.New() |
| 15 | |
| 16 | //设置dotserver日志目录 |
| 17 | //如果不设置,默认不启用,且默认为当前目录 |
| 18 | app.SetEnabledLog(true) |
| 19 | |
| 20 | //开启development模式 |
| 21 | app.SetDevelopmentMode() |
| 22 | |
| 23 | app.UseTimeoutHook(dotweb.DefaultTimeoutHookHandler, time.Second*10) |
| 24 | |
| 25 | exAccessFmtLog := NewAccessFmtLog("appex") |
| 26 | exAccessFmtLog.Exclude("/index") |
| 27 | exAccessFmtLog.Exclude("/v1/machines/queryIP/:IP") |
| 28 | app.Use(exAccessFmtLog) |
| 29 | |
| 30 | app.ExcludeUse(NewAccessFmtLog("appex1"), "/") |
| 31 | app.Use( |
| 32 | NewAccessFmtLog("app"), |
| 33 | ) |
| 34 | //设置路由 |
| 35 | InitRoute(app.HttpServer) |
| 36 | |
| 37 | //启动 监控服务 |
| 38 | app.SetPProfConfig(true, 8081) |
| 39 | |
| 40 | // 开始服务 |
| 41 | port := 8080 |
| 42 | fmt.Println("dotweb.StartServer => " + strconv.Itoa(port)) |
| 43 | err := app.StartServer(port) |
| 44 | fmt.Println("dotweb.StartServer error => ", err) |
| 45 | } |
| 46 | |
| 47 | func Index(ctx dotweb.Context) error { |
| 48 | ctx.Response().Header().Set("Content-Type", "text/html; charset=utf-8") |
nothing calls this directly
no test coverage detected