MCPcopy Create free account
hub / github.com/devfeel/dotweb / main

Function main

example/middleware/main.go:12–45  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10)
11
12func 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
47func Index(ctx dotweb.Context) error {
48 ctx.Response().Header().Set("Content-Type", "text/html; charset=utf-8")

Callers

nothing calls this directly

Calls 11

NewFunction · 0.92
NewAccessFmtLogFunction · 0.85
SetDevelopmentModeMethod · 0.80
UseTimeoutHookMethod · 0.80
ExcludeUseMethod · 0.80
SetPProfConfigMethod · 0.80
StartServerMethod · 0.80
InitRouteFunction · 0.70
SetEnabledLogMethod · 0.65
ExcludeMethod · 0.65
UseMethod · 0.65

Tested by

no test coverage detected