Skip to content

Instantly share code, notes, and snippets.

@zishe
Created April 3, 2014 02:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zishe/9947025 to your computer and use it in GitHub Desktop.
Save zishe/9947025 to your computer and use it in GitHub Desktop.
martini simple server
package main
import (
"github.com/go-martini/martini"
"github.com/martini-contrib/render"
"runtime"
)
type myClassic struct {
*martini.Martini
martini.Router
}
func withoutLogging() *myClassic {
r := martini.NewRouter()
m := martini.New()
m.Use(martini.Recovery())
m.Use(martini.Static("public"))
m.MapTo(r, (*martini.Routes)(nil))
m.Action(r.Handle)
return &myClassic{m, r}
}
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
m := withoutLogging()
martini.Env = martini.Prod
m.Use(render.Renderer())
m.Get("/", func(r render.Render) {
r.HTML(200, "hello", "jeremy")
})
m.Run()
}
<h2>Hello {{.}}!</h2>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment