import "github.com/go-martini/martini" func main() { m := martini.Classic() m.Get("/", func() string { return "Hello, world!" }) m.Run() }
import ( "github.com/go-martini/martini" "encoding/json" ) type Person struct { Name string `json:"name"` Age int `json:"age"` } func main() { m := martini.Classic() m.Post("/person", func(context martini.Context, request *http.Request) (int, string) { decoder := json.NewDecoder(request.Body) var person Person err := decoder.Decode(&person) if err != nil { return http.StatusInternalServerError, "" } // Do something with person data output, _ := json.Marshal(person) return http.StatusOK, string(output) }) m.Run() }This code sets up a web application that handles a POST request to a URL "/person" and returns a JSON response containing the name and age of the person provided in the request body. Overall, ClassicMartini is a package library that provides powerful and simple features for building web applications in Go.