2 回答
TA贡献1906条经验 获得超10个赞
您确定到达了正确的终点吗?
请参阅那个小示例(您可以尝试在您的主机上进行检查)
$ tree
.
├── main.go
└── wwwroot
└── test.js
1 directory, 2 files
$ cat main.go
package main
import (
"net/http"
"github.com/gorilla/mux"
)
func main() {
mux := mux.NewRouter()
mux.PathPrefix("/").Handler(http.FileServer(http.Dir("./wwwroot")))
http.ListenAndServe(":8080", mux)
}
$ cat wwwroot/test.js
$ go run main.go &
[1] 11841
$ curl -v http://localhost:8080/test.js
* Trying ::1:8080...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> GET /test.js HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.65.3
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Content-Length: 0
< Content-Type: application/javascript
< Last-Modified: Thu, 26 Sep 2019 12:12:15 GMT
< Date: Thu, 26 Sep 2019 12:15:36 GMT
<
* Connection #0 to host localhost left intact
- 2 回答
- 0 关注
- 119 浏览
添加回答
举报