Http服务
基础的Http服务和Router以及Context处理
路由定义
firmeve路由是基于httprouter进行扩展,更多httprouter用法参见其文档
//基础示例
router := http.New(firmeve.New())
router.GET("/ping", func(ctx contract.Context) {
ctx.RenderWith(200,render2.Plain,"pong")
ctx.Next()
})路由中间件
router.GET("/ping", func(ctx contract.Context) {
ctx.RenderWith(200,render2.Plain,"pong")
ctx.Next()
}).Use(func(ctx contract.Context) {
ctx.RenderWith(200,render2.Plain,"Before")
ctx.Next()
}).Use(func(ctx contract.Context) {
ctx.RenderWith(200,render2.Plain,"After")
ctx.Next()
})路由分组
启动Http服务
Http服务
Https服务
Http2服务
假设
server.key,server.crt和main在同一目录
Context
可用方法
Last updated
Was this helpful?