Iris简单实现Go web服务器

package main

import (
	"github.com/kataras/iris"
)

func main()  {
	app := iris.New() // 实例一个iris对象

	//配置路由
	app.Get("/", func(ctx iris.Context) {
		ctx.WriteString("Hello Iris")
	})

	app.Get("/aa", func(ctx iris.Context) {
		ctx.WriteString("bb")
	})

	app.Post("/aa", func(ctx iris.Context) {
		ctx.WriteString("postbb")
	})

	// 路由分组
	party := app.Party("/hello")
	// 此处它的路由地址是: /hello/world
	party.Get("/world", func(ctx iris.Context) {
		ctx.WriteString("hello world")
	})

	// 启动服务器
	app.Run(iris.Addr(":7999"))

}

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

发布了12 篇原创文章 · 获赞 1 · 访问量 2236

猜你喜欢

转载自blog.csdn.net/zhanghe_zht/article/details/105658222