Name: mercurius
Owner: Novatrix Technologies
Description: Mercurius gives you speed when create 'Go' applications. It lets you being focused at business.
Created: 2016-10-09 14:23:31.0
Updated: 2017-12-17 03:55:48.0
Pushed: 2017-12-26 17:45:08.0
Homepage: null
Size: 5020
Language: Go
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Mercurius gives you speed to create new 'Go' web applications. It let you more focused on your business than in your backend.
Get a web application template for Golang that includes: Internationalization, Routers, Logging, Cache, Database, Jade Template Render Engine, JWT, oAuth 2.0. Built on top of Macaron, all items are configured and ready to use.
o install github.com/novatrixtech/mercurius```
ercurius new```
RTANT: Mercurius must be called from developer's GOPATH/src dir
ructure of a Project
/conf Application configuration including environment-specific configs
/conf/app Middlewares and routes configuration
/handler HTTP handlers
/locale Language specific content bundles
/lib Common libraries to be used across your app
/model Models
/public Web resources that are publicly available
/public/templates Jade templates or Native templates
/repository Database comunication following repository pattern
main.go Application entry
eating routes
p all your routes inside the `SetupRoutes` func in `conf/app/app.go`
func SetupRoutes(app *macaron.Macaron) {
app.Group("", func() {
app.Get("/", handler.ListAccessPage)
}, auth.LoginRequired)
app.Get("/login", handler.LoginPage)
app.Post("/login", binding.BindIgnErr(model.Login), handler.BasicAuth)
})
}
eating handlers for the routers
all handler files inside the handler folder
Handle raw text**
func Hello() string {
return "Hello"
}
Handle JSON**
import (
"net/http"
"{{.AppPath}}/lib/contx"
)
func User(ctx *contx.Context) {
//user is the struct you want to return
ctx.JSON(http.StatusOk, user)
}
Handle XML**
import (
"net/http"
"{{.AppPath}}/lib/contx"
)
func User(ctx *contx.Context) {
//user is the struct you want to return
ctx.XML(http.StatusOk, user)
}
Handle Jade HTML Template Engine**
extension of the templates must be `.jade`. Put the jade files inside public/templates folder
import (
"net/http"
"{{.AppPath}}/lib/contx"
)
func User(ctx *contx.Context) {
//edit is the page name you want to render
ctx.HTML(http.StatusOk, "edit")
}
Handle Go HTML Template Engine**
extension of the templates must be `.tmpl or .html`. Put the Go template files inside public/templates folder
import (
"net/http"
"{{.AppPath}}/lib/contx"
)
func User(ctx *contx.Context) {
//edit is the page name you want to render
ctx.NativeHTML(http.StatusOk, "edit")
}
o deploy only the binary file
des binary file you need to copy locale, conf and public directories along with it in order to a Mercurius project works properly.