gouweb
is a web framework for go inspired by laravel
Installation
go get -u github.com/MikhailBatsin-code/gouweb
Project
your project need to have this structure:
project_root/
main.go
go.mod
handlers/
your handlers...
config/
config.go
routes/
routes.go
views/
your views...
templates/
your templates...
database/
migrations/
miglist.json(this is for cli)
your migrations...
models/
modelslist.json(this is for cli too)
your models...
Hello world
write in handlers/index.go basic hello world(dont forget imports and package declaration):
func IndexHandler(*gin.Context) {
c.JSON(200, map[string]string{"Hello": "World"})
}
in routes.go:
var Routes routes.Router = routes.NewRouter(gin.Default())
func ApplyRoutes() {
Routes.AddRoute("/".
map[string]func(*gin.Context){
"GET": handlers.IndexHandler,
})
}
in main.go:
func main() {
// import your routes
routes.ApplyRoutes()
server := servers.DevServer({Router: routes.Routes, Port: 5000})
server.run()
}
This is pretty big code for hello world. But it is not for little projects. Also wait for example code on my account where i will show you how to use it