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/kataras/iris" "github.com/kataras/iris/middleware/logger" "github.com/kataras/iris/middleware/recover" )
func main() { app := iris.New() app.Use(recover.New()) app.Use(logger.New())
app.Handle("GET", "/", func(ctx iris.Context) { ctx.HTML("<h1>Welcome</h1>") })
app.Get("/ping", func(ctx iris.Context) { ctx.WriteString("pong") })
app.Get("/hello", func(ctx iris.Context) { ctx.JSON(iris.Map{"message": "Hello Iris!"}) })
app.Run(iris.Addr(":8080")) }
|