WebgoGo 實現(xiàn)的 Web 框架
webgo,a golang web framework for vectors ERP system
框架提供關(guān)于 Http 服務(wù)器端最精簡邏輯實現(xiàn),理論上可以兼容大部分其他框架中間件(需要小量修改)。
服務(wù)器目錄樹 App │ ├─module 應(yīng)用模塊目錄 │ ├─web 模塊目錄 │ │ ├─static 靜態(tài)資源目錄 │ │ │ ├─uploads 上傳根目錄 │ │ │ ├─lib 資源庫文件目錄(常用作前端框架庫) │ │ │ └─src 資源文件 │ │ │ ├─js 資源Js文件目錄 │ │ │ ├─img 資源圖片文件目錄 │ │ │ └─css 資源Css文件 │ │ ├─model 模型目錄 │ │ ├─template 視圖文件目錄 │ │ ├─data 數(shù)據(jù)目錄 │ │ ├─model 模型目錄 │ │ └─controller.go 控制器 │ │ │ ├─base 模塊目錄 │ │ │ └─... 擴展的可裝卸功能模塊或插件 │ ├─static 靜態(tài)資源目錄 │ ├─uploads 上傳根目錄 │ ├─lib 資源庫文件目錄(常用作前端框架庫) │ └─src 資源文件 │ ├─js 資源Js文件目錄 │ ├─img 資源圖片文件目錄 │ └─css 資源Css文件 ├─template 視圖文件目錄 ├─deploy 部署文件目錄 │ ├─main.go 主文件 └─main.ini 配置文件
hello world demo
package main
import (
"fmt"
"github.com/VectorsOrigin/web"
)
type (
ctrls struct {
}
)
func (self ctrls) hello_world(hd *web.THandler) {
hd.RespondString("Hello Webgo World!")
}
func main() {
srv := web.NewServer("")
srv.Get("/hello", ctrls.hello_world)
srv.Get("/hello2", func(c *web.THandler) {
c.RespondString("Hello, World")
return
})
srv.Get("/hello3", func(c *web.THandler) {
c.RenderTemplate("hello_world.html", map[string]interface{}{"static": "youpath"})
fmt.Println("b", c.Route.FilePath)
return
})
srv.Listen(":8080")
}評論
圖片
表情
