douya6606 2016-03-25 20:33
浏览 117
已采纳

Go应用在本地运行良好,运行GoApp服务时产生404

I have a written a REST API using the Gorilla mux package and all data is stored in a MySQL database. I'm using the go-sql-driver/mysql package to access it.

When I compile and run the bin directly, it works as expected.

This is my first attepmt at deploying about to google cloud services, so I'm not familair with any special setup thatr needs to occur to make this work.

All code can be found at cobraclamp/hotswapper-api

NOTE: I'm aware that the InitDB in main has boilerplate credentials, they are properly set in the local and production projects

  • 写回答

1条回答 默认 最新

  • duancashi1362 2016-03-26 09:09
    关注

    I haven't trawled through all your code, but I guess the problem is you initialise your router in main.

    As per the App Engine go SDK docs and the Gorilla mux docs, you need to do this in an init() function:

    Or, for Google App Engine, register it in a init() function:

    func init() {
        http.Handle("/", router)
    }
    

    If you don't do this I guess your app will get a 404 for any route.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于github的项目怎么在pycharm上面运行
  • ¥15 内存地址视频流转RTMP
  • ¥100 有偿,谁有移远的EC200S固件和最新的Qflsh工具。
  • ¥15 找一个QT页面+目标识别(行人检测)的开源项目
  • ¥15 有没有整苹果智能分拣线上图像数据
  • ¥20 有没有人会这个东西的
  • ¥15 cfx考虑调整“enforce system memory limit”参数的设置
  • ¥30 航迹分离,航迹增强,误差分析
  • ¥15 Chrome Manifest扩展引用Ajax-hook库拦截请求失败
  • ¥15 用Ros中的Topic通讯方式控制小乌龟的速度,走矩形;编写订阅器代码