Richard Bucker

labstack echo - nice http server in go

Posted at — Oct 8, 2015

The echo http server is pretty nice even though it’s missing a feature or two.


func main() {
        flag.Parse()

        // Echo instance
        e := echo.New()

        // Middleware
        e.Use(mw.Logger())
        e.Use(mw.Recover())

        e.Static(“/public”, “www/public”)
        // Routes
        e.Index(“public/index.html”)
        e.ServeFile(“/welcome”, “welcome.html”)
        e.ServeFile(“/styles.css”, “styles.css”)
        e.Get(“/a”, hello)

        // Start server
        log.Printf(“Listening to port: %v”, *bindto)
        e.Run(*bindto)
}

Some good stuff