import "github.com/martini-contrib/render" func main() { r := martini.Classic() r.Use(render.Renderer()) r.Get("/", func(r render.Render) { r.Text(200, "Hello, world!") }) r.Run() }
import "github.com/martini-contrib/render" func main() { r := martini.Classic() r.Use(render.Renderer()) r.Get("/:name", func(params martini.Params, r render.Render) { name := params["name"] message := fmt.Sprintf("Hello, %s!", name) r.Text(200, message) }) r.Run() }This example shows how to use dynamic URL parameters and the "fmt" package to generate personalized text responses for different names. In conclusion, the "github.com/martini-contrib/render" package is a useful third-party library for adding HTTP render support to your Martini applications. It provides many methods for rendering different types of responses, including plain text, and makes it easy to generate dynamic responses with personalized messages.