第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

`alice` 沒有調(diào)用中間件

`alice` 沒有調(diào)用中間件

Go
肥皂起泡泡 2021-09-13 20:07:18
為什么這里只調(diào)用了 的ServeHTTP方法,H1而H2和 的方法H3似乎被忽略了?alice似乎是一個不錯的中間件鏈接,在這里我嘗試將它與httprouter一起使用,但只有外部/最后一個中間件被調(diào)用:package mainimport (    "fmt"    "github.com/julienschmidt/httprouter"    "github.com/justinas/alice"    "net/http"    "log"    "time")func main() {    fmt.Println("started ", time.Now())    c := alice.New(S1, S2, S3).Then(nil)    router := httprouter.New()    router.Handler("GET", "/app", c)    http.ListenAndServe(":27007", router)}func S1(h http.Handler) http.Handler {    var x H1    return &x}func S2(h http.Handler) http.Handler {    var x H2    return &x}func S3(h http.Handler) http.Handler {    var x H3    return &x}type H1 struct{}func (h *H1) ServeHTTP(rw http.ResponseWriter, req *http.Request) {    log.Println("H1", time.Now())}type H2 struct{}func (h *H2) ServeHTTP(rw http.ResponseWriter, req *http.Request) {    log.Println("H2")}type H3 struct{}func (h *H3) ServeHTTP(rw http.ResponseWriter, req *http.Request) {    log.Println("H3")}
查看完整描述

2 回答

  • 2 回答
  • 0 關(guān)注
  • 223 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號