ego008
ego008
3850 0 0

新的可关注的go web 框架 -- gas

从iris 最新的性能表发现gas

iris https://github.com/kataras/iris

gas https://github.com/go-gas/gas 虽然当前只有123颗星,挺看好它。

gas 的设计结构比较精简、清晰,iris 是个大馄饨。

微应用结构:

|-- $GOPATH
|   |-- src
|       |--Your_Project_Name
|          |-- main.go
|          |-- config.yaml

code:

package main

import (
"github.com/go-gas/gas"
"net/http"
)

func main() {
g := gas.Default("config.yaml")

g.Router.Get("/", Index)
g.Router.Get("/user", GetUser)

g.Run()
}

func Index(ctx *gas.Context) error {
return ctx.HTML(http.StatusOK, "Micro service! <br> <a href="/user">json response example</a>")
}

func GetUser(ctx *gas.Context) error {
return ctx.JSON(http.StatusOK, gas.H{
"name": "John",
"age":  32,
})
}

大工程结构:

|-- $GOPATH
|   |-- src
|       |--Your_Project_Name
|          |-- config
|              |-- default.yaml
|          |-- controllers
|              |-- default.go
|          |-- log
|          |-- models
|          |-- routers
|              |-- routers.go
|          |-- static
|          |-- views
|          |-- main.go

更新

gas 的作者已经放弃 gas 框架,加入到 gin 的维护中去,并成为主力开发者。

0

See Also

Nearby


Discussion

Login Topics