import ( "github.com/go-martini/martini" ) func main() { m := martini.Classic() m.Get("/", func(ctx martini.Context) { ctx.WriteString("Hello, world!") }) m.Run() }
import ( "github.com/go-martini/martini" "net/http" ) func main() { m := martini.Classic() m.Use(func(ctx martini.Context, res http.ResponseWriter) { res.Header().Set("Content-Type", "text/plain; charset=utf-8") }) m.Get("/", func(ctx martini.Context, res http.ResponseWriter) { res.Write([]byte("Hello, world!")) }) m.Run() }In this example, we again use the `Classic()` method to create a Martini instance, but this time we use the `Use()` method to define a middleware function that sets the `Content-Type` header of the response to `text/plain; charset=utf-8`. We then define a route for the root URL and use the `Write()` method of the ResponseWriter object to write the response. Overall, the go-martini package provides a convenient and easy-to-use way to build Go web applications, with the Context package providing middleware functionality and easy handling of HTTP requests and responses.