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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Golang 中的服務(wù)器頭中間件

Golang 中的服務(wù)器頭中間件

Go
慕斯王 2021-08-10 15:10:47
我正在嘗試在每個(gè)響應(yīng)上設(shè)置服務(wù)器標(biāo)頭。我正在嘗試使用Gin的中間件來(lái)實(shí)現(xiàn)這一點(diǎn)。但是,由于某種原因,這不會(huì)設(shè)置標(biāo)題。到目前為止,我已經(jīng)嘗試對(duì)此進(jìn)行調(diào)試,但我不明白為什么這不起作用??赡芪以谶@里遺漏了一些東西。這是代碼package mainimport "fmt"import "github.com/gin-gonic/gin"const SERVER_INFO = "Some-Play-Server"type ServerHeader struct {    gin.ResponseWriter    ServerInfo string}func (w *ServerHeader) Write(data []byte) (int, error) {    if w.Header().Get("Server") == "" {        w.Header().Add("Server", w.ServerInfo)    }    return w.ResponseWriter.Write(data)}func InitServerHeader() gin.HandlerFunc {    return func(c *gin.Context) {        writer := &ServerHeader{c.Writer, SERVER_INFO}        c.Writer = writer        c.Next()    }}func main() {    mux := gin.Default()    mux.Use(InitServerHeader())    mux.GET("/", func(c *gin.Context) {        c.String(200, "OK")    })    fmt.Println("Server Listening on 0.0.0.0:8080")    mux.Run(":8080")}而且,這是測(cè)試輸出? curl -v http://localhost:8080/* About to connect() to localhost port 8080 (#0)* Connected to localhost (::1) port 8080 (#0)> GET / HTTP/1.1> User-Agent: curl/7.30.0> Host: localhost:8080> Accept: */*> < HTTP/1.1 200 OK< Content-Type: text/plain< Date: Wed, 13 Aug 2014 16:54:21 GMT< Content-Length: 2< OK
查看完整描述

3 回答

  • 3 回答
  • 0 關(guān)注
  • 185 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

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