forked from devfeel/dotweb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
41 lines (34 loc) · 898 Bytes
/
main.go
File metadata and controls
41 lines (34 loc) · 898 Bytes
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 (
"github.com/devfeel/dotweb"
"fmt"
"strconv"
"github.com/devfeel/dotweb/logger"
)
const loggerFileName = "develop-mode"
func main(){
app := dotweb.New()
//if use develop mode
//1. Enabled Log
//2. use RequestLogMiddleware
//3. Enabled Console Print
app.SetDevelopmentMode()
//设置路由
InitRoute(app.HttpServer)
// 开始服务
port := 8080
fmt.Println("dotweb.StartServer => " + strconv.Itoa(port))
err := app.StartServer(port)
fmt.Println("dotweb.StartServer error => ", err)
}
// Index index action
func Index(ctx dotweb.Context) error {
ctx.Response().Header().Set("Content-Type", "text/html; charset=utf-8")
ctx.WriteString(ctx.Request().URL.Path)
logger.Logger().Debug("Index:WriteString " + ctx.Request().URL.Path, loggerFileName)
return nil
}
// InitRoute init routes
func InitRoute(server *dotweb.HttpServer) {
server.GET("/", Index)
}