forked from devfeel/dotweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
37 lines (30 loc) · 772 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
package main
import (
"github.com/devfeel/dotweb"
"fmt"
"strconv"
)
func main(){
app := dotweb.Classic()
//app := dotweb.New()
//开启development模式
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)
//_, err := ctx.WriteStringC(201, "index => ", ctx.RemoteIP(), "我是首页")
return nil
}
// InitRoute init routes
func InitRoute(server *dotweb.HttpServer) {
server.GET("/", Index)
}