-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (45 loc) · 1.08 KB
/
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
42
43
44
45
46
47
48
49
50
51
package main
import (
_ "github.com/go-sql-driver/mysql"
"github.com/kataras/iris"
"my_demo/middlewares"
"my_demo/models/db"
"my_demo/view"
)
func initRouter(app *iris.Application){
view.RegisterTestRouters(app)
}
func main(){
app := iris.New()
app.UseGlobal(middlewares.AbnormalHandle,middlewares.RequestLogHandle)
initRouter(app)
db.InitDB()
//app.Get("/get_request", func(ctx iris.Context){
// app.Logger().Info(ctx.Path())
// //ctx.WriteString(ctx.Path())
//
// //user := ctx.URLParam("user")
// //app.Logger().Info(user)
// //ctx.HTML("<h1>"+user+"</h1>")
// ctx.JSON(iris.Map{"message":"hello","requestcode":200})
//})
//
//app.Post("/post_login", func(ctx iris.Context){
// app.Logger().Info(ctx.Path())
//
// //user := ctx.PostValue("user")
// //ctx.WriteString(user)
// var person Person
// if err := ctx.ReadJSON(&person);err != nil{
// panic(err.Error())
// }
//
// ctx.Writef("%#+v\n",person)
//
//})
app.Run(iris.Addr(":8088"),iris.WithoutServerError(iris.ErrServerClosed))
}
type Person struct {
Name string `json:"name"`
Age int `json:"age"`
}