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>

        RivetHTTP 路由管理器

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

        專注路由.簡潔, 貪心匹配, 支持注入, 可定制, 深度解耦的 http 路由管理器.

        examples 目錄中有幾個例子, 方便您了解 Rivet.這里有個路由專項評測 go-http-routing-benchmark.

        示例代碼:

        package main
        
        import (
            "io"
            "net/http"
        
            "github.com/typepress/rivet"
        )
        
        // 常規(guī)風(fēng)格 handler
        func HelloWord(rw http.ResponseWriter, req *http.Request) {
            io.WriteString(rw, "Hello Word")
        }
        
        /**
        帶參數(shù)的 handler.
        params 是從 URL.Path 中提取到的參數(shù).
        params 的另一種風(fēng)格是 PathParams/Scene. 參見 Scene.
        */
        func Hi(params rivet.Params, rw http.ResponseWriter) {
            io.WriteString(rw, "Hi "+params.Get("who")) // 提取參數(shù) who
        }
        
        func main() {
        
            // 新建路由管理器
            mux := rivet.NewRouter(nil) // 下文解釋參數(shù) nil
        
            // 注冊路由
            mux.Get("/", HelloWord)
            mux.Get("/:who", Hi) // 參數(shù)名設(shè)定為 "who"
        
            // rivet.Router 符合 http.Handler 接口
            http.ListenAndServe(":3000", mux) 
        }
        瀏覽 18
        點(diǎn)贊
        評論
        收藏
        分享

        手機(jī)掃一掃分享

        編輯 分享
        舉報
        評論
        圖片
        表情
        推薦
        點(diǎn)贊
        評論
        收藏
        分享

        手機(jī)掃一掃分享

        編輯 分享
        舉報
        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>
            国产不卡视频 | 精品国产91久久久久久一区黄 | 黄色成人播放免费 | 高潮videossex高潮 | 操学生逼 | 91亚洲成人精品性色 | 日本操逼逼 | 亚洲AV无码黑人专区 | 无码三级 | 久99久在线 |