douli1306 2015-12-31 18:53
浏览 42

HTTP服务器仅从浏览器提供“ /”

I basically cut and pasted the example to make a web server from this link: http://thenewstack.io/building-a-web-server-in-go/

Posted the code here: http://play.golang.org/p/RvEr7E-v9q

I run the server and put in browser "localhost:8080" and this calls the hello(w,r) handler as expected. When trying from browser "localhost/stuff:8080" it doesn't even call the ServeHTTP(w http.ResponseWriter, r *http.Request)

What fundamentally ridiculous thing am I doing wrong here?

Thanks

  • 写回答

1条回答 默认 最新

  • dongqiang5541 2015-12-31 18:58
    关注

    Yes. You're not using a valid url. The port number comes before the path. The scheme below describes a url. You hsould have localhost:8080/whatever/the/path/is and never localhost/some/path/this/should/never/work/because/its/not/valid:8080

    scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]

    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么