Martini是一个功能强大的软件包,用于在Golang中快速编写模块化Web应用程序/服务。
下载
$ go get github.com/go-martini/martini
Demo
server.go
//server.gopackage mainimport "github.com/go-martini/martini"func main() { ?m := martini.Classic() ?m.Get("/", func() string { ???return "Hello world!" ?}) ?m.Run()}
启动一个HTTP server,监听3000端口。
编译和执行
$ go build server.go$ ./server[martini] listening on :3000 (development)[martini] Started GET / for [::1]:57956[martini] Completed 200 OK in 184.546μs
client请求
$ curl http://localhost:3000Hello world!%
参考
github martini
golang web framework--Martini
原文地址:https://www.cnblogs.com/lanyangsh/p/10293491.html