ThinkGo:一個輕量級的 Go 語言 MVC 框架

ThinkGo 是一個輕量級的 Go 語言 MVC 框架,目前支持路由、中間件、控制器、請求、響應、Session、視圖、日誌、緩存、ORM等 web 框架應該具備的基本功能,ThinkGo致力於讓代碼簡潔且富於表達力,幫助開發者快速構建一個 Web 應用。

特性

  • 簡潔的路由,支持參數注入
  • 強大的路由中間件,支持前置/後置中間件
  • Session支持,支持cookie、redis及自定義存儲
  • 強大的日誌服務,支持多通道存儲,遵循RFC 5424規範。
  • 緩存,支持memory、redis及自定義緩存驅動
  • 簡潔的ORM,能使用原生 SQL、流暢的查詢構造器

安裝

go get github.com/thinkoner/thinkgo

快速開始

package main

import (
    "github.com/thinkoner/thinkgo"
    "fmt"
    "github.com/thinkoner/thinkgo/router"
    "github.com/thinkoner/thinkgo/context"
)

func main() {
    app := thinkgo.BootStrap()
    app.RegisterRoute(func(route *router.Route) {

        route.Get("/", func(req *context.Request) *context.Response {
            return thinkgo.Text("Hello ThinkGo !")
        })

        route.Get("/ping", func(req *context.Request) *context.Response {
            return thinkgo.Json(map[string]string{
                "message": "pong",
            })
        })

        // Dependency injection
        route.Get("/user/{name}", func(req *context.Request, name string) *context.Response {
            return thinkgo.Text(fmt.Sprintf("Hello %s !", name))
        })
    })
    // listen and serve on 0.0.0.0:9011
    app.Run()
}

協議

ThinkGo 採用 Apache 2.0 開源協議發佈。

項目地址

聯繫作者

https://github.com/thinkoner/...

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章