1. <strong id="7actg"></strong>
    2. <table id="7actg"></table>

    3. <address id="7actg"></address>
      <address id="7actg"></address>
      1. <object id="7actg"><tt id="7actg"></tt></object>

        go_wtfGo 開發(fā)的 Web 框架

        聯(lián)合創(chuàng)作 · 2023-09-20 05:05

        WTF 是小型的Web框架:Web Tiny Framework

        WTF的目標(biāo)不是重度框架,不考慮涵蓋所有功能,重點(diǎn)放在簡(jiǎn)單和靈活性上

        其實(shí)現(xiàn)了一個(gè)非常靈活的路由(Mux),并且路由的使用方法也極簡(jiǎn)單

        還通過中間件(Midware)的方式實(shí)現(xiàn)了gzip等常用功能

        所有的組件都通過接口來(lái)耦合,意味著開發(fā)者可以自己實(shí)現(xiàn)自己的組件,替換到WTF中

        一個(gè)最簡(jiǎn)單的例子:

        package main
        
        import (
            "github.com/i11cn/go_wtf"
            "net/http"
        )
        
        func main() {
            serv := wtf.NewServer()
            serv.HandleFunc(func(ctx wtf.Context){
                ctx.WriteString("點(diǎn)啥都是這一頁(yè)")
            }, "/*")
            http.ListenAndServe(":4321", serv)
        }

        一個(gè)稍微復(fù)雜點(diǎn)的例子:

        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("點(diǎn)啥都是這一頁(yè)")
            }, "/*")
            http.ListenAndServe(":4321", serv)
        }
        瀏覽 24
        點(diǎn)贊
        評(píng)論
        收藏
        分享

        手機(jī)掃一掃分享

        編輯 分享
        舉報(bào)
        評(píng)論
        圖片
        表情
        推薦
        點(diǎn)贊
        評(píng)論
        收藏
        分享

        手機(jī)掃一掃分享

        編輯 分享
        舉報(bào)
        1. <strong id="7actg"></strong>
        2. <table id="7actg"></table>

        3. <address id="7actg"></address>
          <address id="7actg"></address>
          1. <object id="7actg"><tt id="7actg"></tt></object>
            大bbw大bbw超大bbw | 情趣网站在线观看 | 边吃奶一边做爰 | av网站免费在线观看 | 国产精品久久久久久久免费看 | 欧美日韩国产性爱 | 超碰在线1| 美女被操免费视频 | 性荷兰videos艳星极品 | 国产一在线 |