Golang的Web框架:handy
介紹
用 Go 實現的一個簡單的 MVC 模式框架,目前支持:
- 路由/RESTFUL(route)
- 控制器(handler)
- 視圖(templates)
- 表單(form)
- 靜態文件(static)
安裝
請確保Go環境已經安裝,如未安裝請參考 Go 環境安裝,請安裝最新版。
go get github.com/go-web-framework/handy 使用
package main
import (
"github.com/go-web-framework/handy"
)
var (
application = &handy.Application{}
)
func main() {
app := application.New(nil)
app.Route.Handle("/", func() string {
return "hello world!"
})
app.Route.Handle("/hello/{val}", func(val string) string {
return "hello " + val
})
app.Route.Handle("/hi/{val}", func(ctx *handy.Context, val string) {
ctx.WriteString("hi " + val)
})
app.Start()
} 啟動程序訪問8080端口,默認端口為8080
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!