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 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)