Created
April 3, 2014 02:02
-
-
Save zishe/9947025 to your computer and use it in GitHub Desktop.
martini simple server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2>Hello {{.}}!</h2> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment