1 Star 0 Fork 0

Wsage/go-framework

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
app.go 660 Bytes
一键复制 编辑 原始数据 按行查看 历史
王少奇 提交于 2021-09-09 16:47 . 恢复
package go_framework
import "net/http"
//应用数据结构
type Application struct{
Name string
Version string
Routers map[string]*Route
}
func NewApp() *Application{
return &Application{
Name:"",
Version:"",
Routers:map[string]*Route{},
}
}
//应用基本信息-名
func (app Application) AppName()string{
return app.Name
}
//添加路由
func (app *Application) Router(route string) *Route {
if _, ok := app.Routers[route]; ok {
return app.Routers[route]
}
app.Routers[route] = &Route{Route: route}
return app.Routers[route]
}
//运行应用
func (app Application) Run(port string) error{
return http.ListenAndServe(port, nil)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/scottq/go-framework.git
git@gitee.com:scottq/go-framework.git
scottq
go-framework
go-framework
v1.1.43

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385