- 授权协议: LGPL
- 开发语言: Google Go
- 操作系统: 跨平台
- 软件首页: https://github.com/i11cn/go_wtf
- 软件文档: https://github.com/i11cn/go_wtf
- 官方下载: https://github.com/i11cn/go_wtf
软件介绍
WTF 是小型的Web框架:Web Tiny Framework
WTF的目标不是重度框架,不考虑涵盖所有功能,重点放在简单和灵活性上
其实现了一个非常灵活的路由(Mux),并且路由的使用方法也极简单
还通过中间件(Midware)的方式实现了gzip等常用功能
所有的组件都通过接口来耦合,意味着开发者可以自己实现自己的组件,替换到WTF中
一个最简单的例子:
package main
import (
"github.com/i11cn/go_wtf"
"net/http"
)
func main() {
serv := wtf.NewServer()
serv.HandleFunc(func(ctx wtf.Context){
ctx.WriteString("点啥都是这一页")
}, "/*")
http.ListenAndServe(":4321", serv)
}一个稍微复杂点的例子:
package main
import (
"github.com/i11cn/go_wtf"
"net/http"
)
type (
my_server struct {
}
)
func (s *my_server) Hello(ctx wtf.Context) {
who := ctx.RESTParams().Get("who")
ctx.WriteString("Hello," + who)
}
func main() {
serv := wtf.NewServer()
my := &my_server{}
serv.Handle(my.Hello, "/hello/:who")
serv.HandleFunc(func(ctx wtf.Context){
ctx.WriteString("点啥都是这一页")
}, "/*")
http.ListenAndServe(":4321", serv)
}
