作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
请不要对我的帖子咄咄逼人,我正在努力学习 Go,但在我的理解上面临一些挑战。
这是我的示例代码:
package main
import (
"log"
"net/http"
"reflect"
"fmt"
)
func main() {
mux := http.NewServeMux()
rh := http.RedirectHandler("http://example.org", 307)
fmt.Println("The type of the object, returned by the RedirectHandler is")
fmt.Println(reflect.TypeOf(rh))
fmt.Println("End with type observation")
mux.Handle("/foo", rh)
log.Println("Listening ...")
http.ListenAndServe(":3000", mux)
}
我的问题是:
最佳答案
- RedirectHandler returns a Handler interface, is this a common pattern and what is the benefit?
- Does that mean that [RedirectHandler returns] a struct that implements that interface?
- If you run my code, you would see that the type of the variable 'rh' is *http.redirectHandler. For such a pointer I am not able to find anything in the http package.
m=all
到查询字符串以显示它们:
https://golang.org/pkg/net/http/?m=all#redirectHandler
关于http - Golang RedirectHandler() 返回接口(interface),以 *http.redirectHandler 结尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63790220/
请不要对我的帖子咄咄逼人,我正在努力学习 Go,但在我的理解上面临一些挑战。 这是我的示例代码: package main import ( "log" "net/ht
我是一名优秀的程序员,十分优秀!