英文:
golang http disable TRACE method
问题
在golang的net/http包中,是否有类似于Apache中的traceEnable
参数?
我有以下类似的代码,但我希望监听GET
、POST
和HEAD
方法,而不监听TRACE
方法。
go func() {
logger.Log(
"level", 1,
"action", "start https",
"addr", opts.httpsAddr,
)
s := &http.Server{
Addr: opts.httpsAddr,
Handler: server,
TLSConfig: &tls.Config{
MinVersion: tls.VersionTLS12,
},
}
http2.ConfigureServer(s, nil)
fatal("failed to start HTTPS: %s", s.ListenAndServeTLS(opts.tlsCrt, opts.tlsKey))
}()
基本上,我想在收到这样的请求时返回405状态码。
curl -v -X TRACE https://<server>
英文:
Is there something like the traceEnable
parameter in apache, in golang net/http?
I do have something like the following, but I do want to listen to GET
, POST
and HEAD
, however not to the TRACE
method
go func() {
logger.Log(
"level", 1,
"action", "start https",
"addr", opts.httpsAddr,
)
s := &http.Server{
Addr: opts.httpsAddr,
Handler: server,
TLSConfig: &tls.Config{
MinVersion: tls.VersionTLS12,
},
}
http2.ConfigureServer(s, nil)
fatal("failed to start HTTPS: %s", s.ListenAndServeTLS(opts.tlsCrt, opts.tlsKey))
}()
Basically I'd like to return a 405 on such a request
curl -v -X TRACE https://<server>
答案1
得分: 1
在golang的net/http包中,没有类似于apache中的traceEnable参数。
你需要在你的处理程序(handler)或中间件(middleware)中自行实现这个功能。
英文:
> Is there something like the traceEnable parameter in apache, in golang net/http?
No.
You have to do that in your handler or middleware.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论